Fix register-wp-admin-settings.php tests based on recent changes to handle email registration

This commit is contained in:
Justin Shreve 2016-09-08 15:38:58 -07:00
parent a36b25a68f
commit 6fafbe855c
1 changed files with 48 additions and 34 deletions

View File

@ -41,10 +41,10 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
* @covers WC_Register_WP_Admin_Settings::__construct
*/
public function test_constructor() {
$settings = new WC_Register_WP_Admin_Settings( $this->page );
$settings = new WC_Register_WP_Admin_Settings( $this->page, 'page' );
$this->assertEquals( has_filter( 'woocommerce_settings_groups', array( $settings, 'register_group' ) ), 10 );
$this->assertEquals( has_filter( 'woocommerce_settings-' . $this->page->get_id(), array( $settings, 'register_settings' ) ), 10 );
$this->assertEquals( has_filter( 'woocommerce_settings_groups', array( $settings, 'register_page_group' ) ), 10 );
$this->assertEquals( has_filter( 'woocommerce_settings-' . $this->page->get_id(), array( $settings, 'register_page_settings' ) ), 10 );
}
/**
@ -52,7 +52,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
* @covers WC_Register_WP_Admin_Settings::register_group
*/
public function test_register_group() {
$settings = new WC_Register_WP_Admin_Settings( $this->page );
$settings = new WC_Register_WP_Admin_Settings( $this->page, 'page' );
$existing = array(
'id' => 'existing-id',
@ -66,7 +66,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'label' => $this->page->get_label(),
),
);
$actual = $settings->register_group( $initial );
$actual = $settings->register_page_group( $initial );
$this->assertEquals( $expected, $actual );
}
@ -80,6 +80,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
array(
array(
'type' => 'some-type-with-no-id',
'option_key' => '',
),
false,
),
@ -92,6 +93,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'desc' => 'Setting Description',
'default' => 'one',
'options' => array( 'one', 'two' ),
'option_key' => '',
),
array(
'id' => 'setting-id',
@ -100,6 +102,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'description' => 'Setting Description',
'default' => 'one',
'options' => array( 'one', 'two' ),
'option_key' => '',
),
),
// Boolean 'desc_tip' defaulting to 'desc' value
@ -110,6 +113,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'title' => 'Setting Name',
'desc' => 'Setting Description',
'desc_tip' => true,
'option_key' => '',
),
array(
'id' => 'setting-id',
@ -117,6 +121,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'label' => 'Setting Name',
'description' => 'Setting Description',
'tip' => 'Setting Description',
'option_key' => '',
),
),
// String 'desc_tip'
@ -127,6 +132,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'title' => 'Setting Name',
'desc' => 'Setting Description',
'desc_tip' => 'Setting Tip',
'option_key' => '',
),
array(
'id' => 'setting-id',
@ -134,6 +140,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'label' => 'Setting Name',
'description' => 'Setting Description',
'tip' => 'Setting Tip',
'option_key' => '',
),
),
// Empty 'title' and 'desc'
@ -141,12 +148,14 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
array(
'id' => 'setting-id',
'type' => 'select',
'option_key' => '',
),
array(
'id' => 'setting-id',
'type' => 'select',
'label' => '',
'description' => '',
'option_key' => '',
),
),
);
@ -158,7 +167,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
* @covers WC_Register_WP_Admin_Settings::register_setting
*/
public function test_register_setting( $input, $expected ) {
$settings = new WC_Register_WP_Admin_Settings( $this->page );
$settings = new WC_Register_WP_Admin_Settings( $this->page, 'page' );
$actual = $settings->register_setting( $input );
@ -181,10 +190,10 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
->with( $this->equalTo( 0 ) )
->will( $this->returnValue( array() ) );
$settings = new WC_Register_WP_Admin_Settings( $this->page );
$settings = new WC_Register_WP_Admin_Settings( $this->page, 'page' );
$expected = array();
$actual = $settings->register_settings( array() );
$actual = $settings->register_page_settings( array() );
$this->assertEquals( $expected, $actual );
}
@ -203,13 +212,16 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
array(
'id' => 'setting-1',
'type' => 'text',
'option_key' => '',
),
array(
'type' => 'no-id',
'option_key' => '',
),
array(
'id' => 'setting-2',
'type' => 'textarea',
'option_key' => '',
),
);
@ -218,7 +230,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
->method( 'get_settings' )
->will( $this->returnValue( $settings ) );
$settings = new WC_Register_WP_Admin_Settings( $this->page );
$settings = new WC_Register_WP_Admin_Settings( $this->page, 'page' );
$expected = array(
array(
@ -226,15 +238,17 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
'type' => 'text',
'label' => '',
'description' => '',
'option_key' => 'setting-1',
),
array(
'id' => 'setting-2',
'type' => 'textarea',
'label' => '',
'description' => '',
'option_key' => 'setting-2',
),
);
$actual = $settings->register_settings( array() );
$actual = $settings->register_page_settings( array() );
$this->assertEquals( $expected, $actual );
}