Skip to content

Commit

Permalink
check for tables versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabrisrp committed May 14, 2024
1 parent e05f394 commit 2381f18
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions tests/Integration/inc/Engine/WPRocketUninstall/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public static function set_up_before_class() {
foreach ( self::getOptionNames() as $option_name ) {
self::$options[ $option_name ] = get_option( $option_name );
}

self::installFresh();
}

public static function tear_down_after_class() {
Expand All @@ -96,8 +94,6 @@ public static function tear_down_after_class() {
}
}

self::uninstallAll();

parent::tear_down_after_class();
}

Expand All @@ -112,6 +108,8 @@ private static function getTransientNames() {
public function set_up() {
parent::set_up();

self::installFresh();

foreach ( self::getOptionNames() as $option_name ) {
add_option( $option_name, 'test' );
}
Expand All @@ -126,6 +124,8 @@ public function set_up() {
}

public function tear_down() {
self::uninstallAll();

foreach ( self::getOptionNames() as $option_name ) {
delete_option( $option_name );
}
Expand All @@ -140,19 +140,15 @@ public function tear_down() {
}

public function testShouldDeleteAll() {
$cache_path = 'vfs://public/wp-content/cache/';
$config_path = 'vfs://public/wp-content/wp-rocket-config/';
$container = apply_filters( 'rocket_container', null );
$rucss_usedcss_table = $container->get( 'rucss_usedcss_table' );
$preload_table = $container->get( 'preload_caches_table' );
$atf_table = $container->get( 'atf_table' );
$cache_path = 'vfs://public/wp-content/cache/';
$config_path = 'vfs://public/wp-content/wp-rocket-config/';
$container = apply_filters( 'rocket_container', null );
$rucss_usedcss_table = $container->get( 'rucss_usedcss_table' );
$preload_table = $container->get( 'preload_caches_table' );
$atf_table = $container->get( 'atf_table' );

$uninstall = new WPRocketUninstall( $cache_path, $config_path, $rucss_usedcss_table, $preload_table, $atf_table );

$this->assertTrue( $rucss_usedcss_table->exists(), 'RUCSS table existence' );
$this->assertTrue( $preload_table->exists(), 'Preload table existence' );
$this->assertTrue( $atf_table->exists(), 'ATF table existence' );

$uninstall->uninstall();

foreach ( self::getOptionNames() as $option_name ) {
Expand All @@ -170,8 +166,8 @@ public function testShouldDeleteAll() {
$this->assertEmpty( $this->filesystem->getListing( $cache_path ) );
$this->assertFalse( $this->filesystem->exists( $config_path ) );

$this->assertFalse( $rucss_usedcss_table->exists(), 'RUCSS table existence' );
$this->assertFalse( $preload_table->exists(), 'Preload table existence' );
$this->assertFalse( $atf_table->exists(), 'ATF table existence' );
$this->assertFalse( get_option( 'wpr_rucss_used_css_version', false ), 'RUCSS table deleted' );
$this->assertFalse( get_option( 'wpr_rocket_cache_version', false ), 'Preload table deleted' );
$this->assertFalse( get_option( 'wpr_above_the_fold_version', false ), 'ATF table deleted' );
}
}

0 comments on commit 2381f18

Please sign in to comment.