Skip to content

Commit

Permalink
update display_no_table_notice() test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabrisrp committed May 14, 2024
1 parent 795f632 commit 2e19068
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,34 @@
Notice;

return [
'tableExistsShouldDisplayNotice' => [
'testShouldDoNothingWhenRucssDisabled' => [
'config' => [
'remove_unused_css' => true,
'remove_unused_css' => false,
'table_exists' => true,
],
'expected' => [
'contains' => true,
'contains' => false,
'content' => $content,
],
],
'disableShouldDoNothing' => [
'testShouldDoNothingWhenTableExists' => [
'config' => [
'remove_unused_css' => false,
'remove_unused_css' => true,
'table_exists' => true,
],
'expected' => [
'contains' => false,
'content' => $content,
],
],
'testShouldDisplayNoticeWhenTableNotExists' => [
'config' => [
'remove_unused_css' => true,
'table_exists' => false,
],
'expected' => [
'contains' => true,
'content' => $content,
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Mockery;
use WP_Rocket\Tests\Fixtures\WP_Filesystem_Direct;
use WP_Rocket\Tests\Integration\AdminTestCase;
use WP_Rocket\Tests\Integration\DBTrait;

/**
* Test class covering \WP_Rocket\Engine\Optimization\RUCSS\Admin\Subscriber::display_no_table_notice
Expand All @@ -14,6 +15,8 @@
* @group AdminOnly
*/
class Test_DisplayNoTableNotice extends AdminTestCase {
use DBTrait;

protected $rucss;

public function set_up() {
Expand All @@ -39,6 +42,10 @@ public function tear_down() {
public function testShouldDoAsExpected( $config, $expected ) {
$this->rucss = $config['remove_unused_css'];

if ( ! $config['table_exists'] ) {
self::uninstallAll();
}

add_filter( 'pre_get_rocket_option_remove_unused_css', [ $this, 'rucss' ] );

$filesystem_mock = Mockery::mock( WP_Filesystem_Direct::class );
Expand Down

0 comments on commit 2e19068

Please sign in to comment.