Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests cleanup #6623

Merged
merged 13 commits into from
May 9, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
return [
'shouldReturnUpdatedArrayWhenEmptyOriginal' => [
'original' => [],
'list' => [
'wp-optimize' => 'wp-optimize/wp-optimize.php',
'list' => [
'' => [
[
'slug' => 'wp-optimize',
'file' => 'wp-optimize/wp-optimize.php',
],
],
],
'expected' => [
'wp-optimize' => 'wp-optimize/wp-optimize.php',
Expand All @@ -14,12 +19,17 @@
'original' => [
'wp-asset-clean-up' => 'wp-asset-clean-up/wpacu.php',
],
'list' =>[
'wp-optimize' => 'wp-optimize/wp-optimize.php',
'list' => [
'' => [
[
'slug' => 'wp-optimize',
'file' => 'wp-optimize/wp-optimize.php',
],
],
],
'expected' => [
'wp-asset-clean-up' => 'wp-asset-clean-up/wpacu.php',
'wp-optimize' => 'wp-optimize/wp-optimize.php',
'wp-optimize' => 'wp-optimize/wp-optimize.php',
],
],
];
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php
return [
'LowerVersionShouldClean' => [
'config' => [
'old_version' => '3.12.1',
],
'LowerVersionShouldClean' => [
'config' => [
'old_version' => '3.12.1',
],
'expected' => true,
],
'HigherVersionShouldDoNothing' => [
'config' => [
'old_version' => '3.15',
],
'HigherVersionShouldDoNothing' => [
'config' => [
'old_version' => '3.15',
],
'expected' => false,
],

],
];
12 changes: 7 additions & 5 deletions tests/Fixtures/inc/ThirdParty/Themes/Avada/excludeDelayJs.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

return [
'shouldReturnUpdatedExclusions' => [
'exclusions' => [],
'expected' => [
'/wp-content/themes/Avada/includes/lib/assets/min/js/library/jquery.flexslider.js',
'/wp-content/themes/Avada/assets/min/js/general/avada-woo-product-images.js',
'test_data' => [
'shouldReturnUpdatedExclusions' => [
'exclusions' => [],
'expected' => [
'/wp-content/themes/avada/includes/lib/assets/min/js/library/jquery.flexslider.js',
'/wp-content/themes/avada/assets/min/js/general/avada-woo-product-images.js',
],
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,58 @@
namespace WP_Rocket\Tests\Integration\inc\Engine\Cache\PurgeActionsSubscriber;

use Brain\Monkey\Functions;
use WP_Rocket\Tests\Integration\DBTrait;
use WP_Rocket\Tests\Integration\FilesystemTestCase;

/**
* Test class covering \WP_Rocket\Engine\Cache\PurgeActionsSubscriber:purge_cache_reject_uri_partially
*/
class Test_PurgeCacheRejectUriPartially extends FilesystemTestCase {
protected $path_to_test_data = '/inc/Engine/Cache/Purge/purgeCacheRejectUriPartially.php';
use DBTrait;

protected $path_to_test_data = '/inc/Engine/Cache/Purge/purgeCacheRejectUriPartially.php';

public static function set_up_before_class()
{
parent::set_up_before_class();
self::installFresh();
}

public static function tear_down_after_class()
{
self::uninstallAll();
parent::tear_down_after_class();
}

public function set_up() {

public function set_up() {

parent::set_up();

$this->set_permalink_structure( '/%postname%/' );
}

/**
/**
* @dataProvider providerTestData
*/
public function testShouldPurgePartiallyWhenCacheRejectUriOptionIsChanged( $config, $expected ) {
if ( ! isset( $expected['cleaned'] ) ) {
Functions\expect( 'home_url' )->never();
Functions\expect( 'rocket_clean_files' )->never();
}
else {
$this->factory->post->create( [
'post_name' => 'hello-world',
'post_title' => 'hello world',
] );

$this->generateEntriesShouldExistAfter( $expected['cleaned'] );

do_action('update_option_' . WP_ROCKET_SLUG , $config['old_value'], $config['value']);

$this->checkEntriesDeleted( $expected['cleaned'] );
$this->checkShouldNotDeleteEntries();
}
}
}
public function testShouldPurgePartiallyWhenCacheRejectUriOptionIsChanged( $config, $expected ) {
if ( ! isset( $expected['cleaned'] ) ) {
Functions\expect( 'home_url' )->never();
Functions\expect( 'rocket_clean_files' )->never();
}
else {
$this->factory->post->create(
[
'post_name' => 'hello-world',
'post_title' => 'hello world',
]
);

$this->generateEntriesShouldExistAfter( $expected['cleaned'] );

do_action( 'update_option_' . WP_ROCKET_SLUG, $config['old_value'], $config['value'] );

$this->checkEntriesDeleted( $expected['cleaned'] );
$this->checkShouldNotDeleteEntries();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

/**
* Test class covering Subscriber::schedule_event
* @uses Subscriber::get_cache_lifespan
* @uses \WP_Rocket\Admin\Options
* @uses \WP_Rocket\Admin\Options_Data
* @uses PurgeExpiredCache
* @group Subscriber
*
* @uses \WP_Rocket\Admin\Options
* @uses \WP_Rocket\Admin\Options_Data
* @group Subscriber
*/
class Test_ScheduleEvent extends TestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

/**
* Test class covering \WP_Rocket\Engine\Cache\WPCache::maybe_prevent_deactivation
* @uses ::find_wp_config_path
*
* @group WPCache
*/
Expand Down
2 changes: 0 additions & 2 deletions tests/Integration/inc/Engine/Cache/WPCache/updateWPCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

/**
* Test class covering \WP_Rocket\Engine\Cache\WPCache::update_wp_cache
* @uses rocket_valid_key()
* @uses ::set_wp_cache_constant
*
* @group WPCache
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use WP_Rocket\Tests\Integration\TestCase;

/**
* Test class covering \WP_Rocket\Engine\Optimization\DynamicLists\Subscriber::add_incompatible_plugins_to_deactivate()
* Test class covering \WP_Rocket\Engine\Optimization\DynamicLists\Subscriber::add_incompatible_plugins_to_deactivate
*
* @group DynamicLists
* @group DynamicLists
*/
class Test_AddIncompatiblePluginsToDeactivate extends TestCase {

public function set_up() {
parent::set_up();

Expand All @@ -28,8 +27,8 @@ public function tear_down() {
/**
* @dataProvider configTestData
*/
public function testShouldReturnExpected( $original, $list, $expected ) {
set_transient( 'wpr_dynamic_lists_incompatible_plugins', $list, HOUR_IN_SECONDS );
public function testShouldReturnExpected( $original, $plugins_list, $expected ) {
set_transient( 'wpr_dynamic_lists_incompatible_plugins', $plugins_list, HOUR_IN_SECONDS );

$this->assertSame(
$expected,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace WP_Rocket\Tests\Integration\inc\Engine\Optimization\Minify\CSS\AdminSubscriber;

use WP_Rocket\Tests\Integration\TestCase;
use Brain\Monkey\Functions;

/**
* Test class covering \WP_Rocket\Engine\Optimization\Minify\CSS\AdminSubscriber::on_update
*
* @group AdminOnly
*/
class Test_OnUpdate extends TestCase {

/**
* @dataProvider configTestData
*/
public function testShouldDoAsExpected( $config, $expected ) {
if ( $expected ) {
Functions\expect( 'rocket_clean_domain' );
} else {
Functions\expect( 'rocket_clean_domain' )->never();
}

do_action( 'wp_rocket_upgrade', '3.15', $config['old_version'] );
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace WP_Rocket\Tests\Integration\inc\Engine\Optimization\Minify\CSS\Subscriber;

use WP_Rocket\Tests\Integration\inc\Engine\Optimization\TestCase;
use Brain\Monkey\Functions;

/**
* Test class covering \WP_Rocket\Engine\Optimization\Minify\CSS\Subscriber::process
* @uses \WP_Rocket\Engine\Optimization\Minify\CSS\Combine::optimize
*
* @uses \WP_Rocket\Engine\Optimization\Minify\CSS\Minify::optimize
* @uses ::get_rocket_parse_url
* @uses ::get_rocket_i18n_uri
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/inc/ThirdParty/Themes/Avada/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function set_stylesheet() {
public function set_stylesheet_root() {
global $wp_theme_directories;

$wp_theme_directories['virtual'] = $this->filesystem->getUrl( 'wp-content/themes/' );
$wp_theme_directories['virtual'] = $this->filesystem->getUrl( 'wp-content/themes' );

return $this->filesystem->getUrl( 'wp-content/themes/' );
return $this->filesystem->getUrl( 'wp-content/themes' );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Test class covering \WP_Rocket\ThirdParty\Themes\Avada::exclude_delay_js
*
* @group Themes
* @group Themes
*/
class Test_ExcludeDelayJs extends TestCase {
protected $path_to_test_data = '/inc/ThirdParty/Themes/Avada/excludeDelayJs.php';
Expand Down
Loading
Loading