This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tests and start using the Options constants
- Loading branch information
Showing
5 changed files
with
76 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Automattic\WooCommerce\Blocks\Tests; | ||
|
||
use Automattic\WooCommerce\Blocks\Migration; | ||
use Automattic\WooCommerce\Blocks\Options; | ||
|
||
class BlockifiedProductGridTemplatesOptionTest extends \WP_UnitTestCase { | ||
public function setUp() { | ||
parent::setUp(); | ||
delete_option( Options::WC_BLOCK_USE_BLOCKIFIED_PRODUCT_GRID_BLOCK_AS_TEMPLATE ); | ||
delete_option( Options::WC_BLOCK_VERSION ); | ||
} | ||
|
||
public function test_switching_to_a_classic_theme_should_set_the_option_to_false() { | ||
switch_theme( 'storefront' ); | ||
check_theme_switched(); | ||
|
||
$this->assertFalse( $this->get_use_blockified_product_grid_templates_option() ); | ||
} | ||
|
||
public function test_switching_from_a_block_to_a_block_theme_should_set_the_option_to_false() { | ||
switch_theme( 'twentytwentytwo' ); | ||
|
||
switch_theme( 'twentytwentytwo' ); | ||
check_theme_switched(); | ||
|
||
$this->assertFalse( $this->get_use_blockified_product_grid_templates_option() ); | ||
} | ||
|
||
public function test_switching_from_a_classic_to_a_block_theme_should_set_the_option_to_true() { | ||
switch_theme( 'twentytwentytwo' ); | ||
check_theme_switched(); | ||
|
||
$this->assertTrue( $this->get_use_blockified_product_grid_templates_option() ); | ||
} | ||
|
||
public function test_running_the_migration_with_a_block_theme_should_set_the_option_to_false() { | ||
switch_theme( 'twentytwentytwo' ); | ||
|
||
update_option( Options::WC_BLOCK_VERSION, 1 ); | ||
Migration::run_migrations(); | ||
|
||
$this->assertFalse( $this->get_use_blockified_product_grid_templates_option() ); | ||
} | ||
|
||
public function test_running_the_migration_with_a_classic_theme_should_set_the_option_to_true() { | ||
switch_theme( 'storefront' ); | ||
|
||
update_option( Options::WC_BLOCK_VERSION, 1 ); | ||
Migration::run_migrations(); | ||
|
||
$this->assertTrue( $this->get_use_blockified_product_grid_templates_option() ); | ||
} | ||
|
||
/** | ||
* Returns the value of the option. | ||
* | ||
* @return boolean | ||
*/ | ||
private function get_use_blockified_product_grid_templates_option() { | ||
return wc_string_to_bool( get_option( Options::WC_BLOCK_USE_BLOCKIFIED_PRODUCT_GRID_BLOCK_AS_TEMPLATE ) ); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.