From 66bc3f2d5c1011f63f70c5489e4c30cf7067afd3 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Mon, 20 Nov 2023 15:15:26 +0100 Subject: [PATCH] style(src) cs fixes --- src/Codeception/Module/WPLoader.php | 60 ++--- tests/_bootstrap.php | 50 ++-- tests/_data/plugins/doing-it-right/plugin.php | 12 +- .../_data/plugins/doing-it-wrong-1/plugin.php | 15 +- .../_data/plugins/doing-it-wrong-2/plugin.php | 15 +- tests/_support/AcceptanceTester.php | 12 +- tests/acceptance/AjaxCest.php | 97 ++++---- .../Codeception/Lib/Generator/WPUnitTest.php | 228 +++++++++--------- .../DoingItRightTest.php | 41 ++-- .../DoingItWrongPluginOneTest.php | 56 +++-- .../DoingItWrongPluginTwoTest.php | 56 +++-- .../wploadersuite/BeforeAfterMethodsTest.php | 35 +-- 12 files changed, 355 insertions(+), 322 deletions(-) diff --git a/src/Codeception/Module/WPLoader.php b/src/Codeception/Module/WPLoader.php index 047df309c..e78128787 100644 --- a/src/Codeception/Module/WPLoader.php +++ b/src/Codeception/Module/WPLoader.php @@ -152,28 +152,28 @@ class WPLoader extends Module */ protected $config = [ - 'loadOnly' => false, - 'isolatedInstall' => true, - 'installationTableHandling' => 'empty', - 'wpDebug' => true, - 'multisite' => false, - 'skipPluggables' => false, - 'dbCharset' => 'utf8', - 'dbCollate' => '', - 'tablePrefix' => 'wptests_', - 'domain' => 'example.org', - 'adminEmail' => 'admin@example.org', - 'title' => 'Test Blog', - 'phpBinary' => 'php', - 'language' => '', - 'configFile' => '', - 'contentFolder' => '', - 'pluginsFolder' => '', - 'plugins' => [], - 'activatePlugins' => [], - 'activatePluginsSilently' => [], - 'bootstrapActions' => '', - 'theme' => '', + 'loadOnly' => false, + 'isolatedInstall' => true, + 'installationTableHandling' => 'empty', + 'wpDebug' => true, + 'multisite' => false, + 'skipPluggables' => false, + 'dbCharset' => 'utf8', + 'dbCollate' => '', + 'tablePrefix' => 'wptests_', + 'domain' => 'example.org', + 'adminEmail' => 'admin@example.org', + 'title' => 'Test Blog', + 'phpBinary' => 'php', + 'language' => '', + 'configFile' => '', + 'contentFolder' => '', + 'pluginsFolder' => '', + 'plugins' => [], + 'activatePlugins' => [], + 'activatePluginsSilently' => [], + 'bootstrapActions' => '', + 'theme' => '', ]; /** @@ -1121,13 +1121,13 @@ public function getContentFolder($path = '') */ protected function getInstallationConfiguration() { - return new Configuration( [ - 'tablesHandling' => isset( $this->config['installationTableHandling'] ) ? - $this->config['installationTableHandling'] - : 'empty', - 'activatePluginsSilently' => isset( $this->config['activatePluginsSilently'] ) ? - (array) $this->config['activatePluginsSilently'] - : [] - ] ); + return new Configuration([ + 'tablesHandling' => isset($this->config['installationTableHandling']) ? + $this->config['installationTableHandling'] + : 'empty', + 'activatePluginsSilently' => isset($this->config['activatePluginsSilently']) ? + (array) $this->config['activatePluginsSilently'] + : [] + ]); } } diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 218a63156..1fe618560 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -9,39 +9,39 @@ createTestDatabasesIfNotExist(); // Make sure traits can be autoloaded from tests/_support/Traits -Autoload::addNamespace( '\lucatume\WPBrowser\Tests\Traits', codecept_root_dir( 'tests/_support/Traits' ) ); +Autoload::addNamespace('\lucatume\WPBrowser\Tests\Traits', codecept_root_dir('tests/_support/Traits')); // If the `uopz` extension is installed, then ensure `exit` and `die` to work normally. -if ( function_exists( 'uopz_allow_exit' ) ) { - uopz_allow_exit( true ); +if (function_exists('uopz_allow_exit')) { + uopz_allow_exit(true); } //addListener( Events::SUITE_BEFORE, function ( Codeception\Event\SuiteEvent $event ) { -// $suiteName = $event->getSuite()->getName(); +// $suiteName = $event->getSuite()->getName(); // -// if ( $suiteName !== 'wploader_plugin_silent_activation' ) { -// return; -// } +// if ( $suiteName !== 'wploader_plugin_silent_activation' ) { +// return; +// } // -// $wpRootDir = realpath( getenv( 'WORDPRESS_ROOT_DIR' ) ); +// $wpRootDir = realpath( getenv( 'WORDPRESS_ROOT_DIR' ) ); // -// if ( ! is_dir( $wpRootDir ) ) { -// throw new \RuntimeException( "The WORDPRESS_ROOT_DIR is not a valid directory." ); -// } +// if ( ! is_dir( $wpRootDir ) ) { +// throw new \RuntimeException( "The WORDPRESS_ROOT_DIR is not a valid directory." ); +// } // -// $wpRootDir = rtrim( $wpRootDir, '/\\' ); +// $wpRootDir = rtrim( $wpRootDir, '/\\' ); // -// foreach ( -// [ -// codecept_data_dir( 'plugins/doing-it-wrong-1' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-1', -// codecept_data_dir( 'plugins/doing-it-wrong-2' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-2', -// ] as $source => $destination -// ) { -// if ( ! copy( -// $source, -// $destination -// ) ) { -// throw new \RuntimeException( "Could not copy the plugin to the WordPress plugins directory." ); -// } -// } +// foreach ( +// [ +// codecept_data_dir( 'plugins/doing-it-wrong-1' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-1', +// codecept_data_dir( 'plugins/doing-it-wrong-2' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-2', +// ] as $source => $destination +// ) { +// if ( ! copy( +// $source, +// $destination +// ) ) { +// throw new \RuntimeException( "Could not copy the plugin to the WordPress plugins directory." ); +// } +// } //} ); diff --git a/tests/_data/plugins/doing-it-right/plugin.php b/tests/_data/plugins/doing-it-right/plugin.php index 1dae79ca4..8467cfd1c 100644 --- a/tests/_data/plugins/doing-it-right/plugin.php +++ b/tests/_data/plugins/doing-it-right/plugin.php @@ -3,11 +3,11 @@ * Plugin Name: Doing It Right */ -register_activation_hook( __FILE__, function () { - update_option( 'doing_it_right_activation', 'activated' ); -} ); +register_activation_hook(__FILE__, function () { + update_option('doing_it_right_activation', 'activated'); +}); -add_action('plugins_loaded', function(){ - global $doing_it_right_plugin_loaded; - $doing_it_right_plugin_loaded = true; +add_action('plugins_loaded', function () { + global $doing_it_right_plugin_loaded; + $doing_it_right_plugin_loaded = true; }); diff --git a/tests/_data/plugins/doing-it-wrong-1/plugin.php b/tests/_data/plugins/doing-it-wrong-1/plugin.php index de849f8da..344c78951 100644 --- a/tests/_data/plugins/doing-it-wrong-1/plugin.php +++ b/tests/_data/plugins/doing-it-wrong-1/plugin.php @@ -3,13 +3,14 @@ * Plugin Name: Doing It Wrong 1 */ -function doing_it_wrong_1_activation(){ - _doing_it_wrong( __FUNCTION__, 'This is a test', '1.0.0' ); - update_option('doing_it_wrong_1j_activation', 'activated'); +function doing_it_wrong_1_activation() +{ + _doing_it_wrong(__FUNCTION__, 'This is a test', '1.0.0'); + update_option('doing_it_wrong_1j_activation', 'activated'); } -register_activation_hook(__FILE__,'doing_it_wrong_1_activation'); +register_activation_hook(__FILE__, 'doing_it_wrong_1_activation'); -add_action('plugins_loaded', function(){ - global $doing_it_wrong_1_plugin_loaded; - $doing_it_wrong_1_plugin_loaded = true; +add_action('plugins_loaded', function () { + global $doing_it_wrong_1_plugin_loaded; + $doing_it_wrong_1_plugin_loaded = true; }); diff --git a/tests/_data/plugins/doing-it-wrong-2/plugin.php b/tests/_data/plugins/doing-it-wrong-2/plugin.php index a193c3360..dfc8502b3 100644 --- a/tests/_data/plugins/doing-it-wrong-2/plugin.php +++ b/tests/_data/plugins/doing-it-wrong-2/plugin.php @@ -3,14 +3,15 @@ * Plugin Name: Doing It Wrong 2 */ -function doing_it_wrong_2_activation() { - _doing_it_wrong( __FUNCTION__, 'This is a test', '1.0.0' ); - update_option('doing_it_wrong_2_activation', 'activated'); +function doing_it_wrong_2_activation() +{ + _doing_it_wrong(__FUNCTION__, 'This is a test', '1.0.0'); + update_option('doing_it_wrong_2_activation', 'activated'); } -register_activation_hook( __FILE__, 'doing_it_wrong_2_activation' ); +register_activation_hook(__FILE__, 'doing_it_wrong_2_activation'); -add_action('plugins_loaded', function(){ - global $doing_it_wrong_2_plugin_loaded; - $doing_it_wrong_2_plugin_loaded = true; +add_action('plugins_loaded', function () { + global $doing_it_wrong_2_plugin_loaded; + $doing_it_wrong_2_plugin_loaded = true; }); diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 8c45540a3..0d1cd504b 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -2,7 +2,6 @@ use PHPUnit\Framework\Assert; - /** * Inherited Methods * @method void wantToTest( $text ) @@ -18,10 +17,11 @@ * * @SuppressWarnings(PHPMD) */ -class AcceptanceTester extends \Codeception\Actor { - use _generated\AcceptanceTesterActions; +class AcceptanceTester extends \Codeception\Actor +{ + use _generated\AcceptanceTesterActions; - /** - * Define custom actions here - */ + /** + * Define custom actions here + */ } diff --git a/tests/acceptance/AjaxCest.php b/tests/acceptance/AjaxCest.php index 3569adefc..88e41dc46 100644 --- a/tests/acceptance/AjaxCest.php +++ b/tests/acceptance/AjaxCest.php @@ -1,8 +1,10 @@ haveMuPlugin( 'test-ajax-plugin', $code ); - } + $I->haveMuPlugin('test-ajax-plugin', $code); + } - public function test_invalid_action_returns_400( AcceptanceTester $I ) { - $I->amOnAdminAjaxPage( [ - 'action' => 'invalid_action' - ] ); - $I->seeResponseCodeIs( 400 ); - } + public function test_invalid_action_returns_400(AcceptanceTester $I) + { + $I->amOnAdminAjaxPage([ + 'action' => 'invalid_action' + ]); + $I->seeResponseCodeIs(400); + } - public function test_missing_nonce_returns_403( AcceptanceTester $I ) { - $I->amOnAdminAjaxPage( [ - 'action' => 'test_ajax_action' - ] ); - $I->seeResponseCodeIs( 403 ); - } + public function test_missing_nonce_returns_403(AcceptanceTester $I) + { + $I->amOnAdminAjaxPage([ + 'action' => 'test_ajax_action' + ]); + $I->seeResponseCodeIs(403); + } - public function test_wrong_nonce_returns_403( AcceptanceTester $I ) { - $I->amOnAdminAjaxPage( [ - 'action' => 'test_ajax_action', - '_ajax_nonce' => 'wrong_nonce' - ] ); - $I->seeResponseCodeIs( 403 ); - } + public function test_wrong_nonce_returns_403(AcceptanceTester $I) + { + $I->amOnAdminAjaxPage([ + 'action' => 'test_ajax_action', + '_ajax_nonce' => 'wrong_nonce' + ]); + $I->seeResponseCodeIs(403); + } - public function test_valid_nonce_returns_200_for_visitor( AcceptanceTester $I ) { - $I->amOnPage( '/' ); - $nonce = $I->grabValueFrom( '#test-ajax-nonce' ); + public function test_valid_nonce_returns_200_for_visitor(AcceptanceTester $I) + { + $I->amOnPage('/'); + $nonce = $I->grabValueFrom('#test-ajax-nonce'); - $I->amOnAdminAjaxPage( [ - 'action' => 'test_ajax_action', - '_ajax_nonce' => $nonce - ] ); - $I->seeResponseCodeIs( 200 ); - $I->canSee( json_encode( [ 'type' => 'no-priv' ] ) ); - } + $I->amOnAdminAjaxPage([ + 'action' => 'test_ajax_action', + '_ajax_nonce' => $nonce + ]); + $I->seeResponseCodeIs(200); + $I->canSee(json_encode([ 'type' => 'no-priv' ])); + } - public function test_valid_nonce_returns_200_for_admin( AcceptanceTester $I ) { - $I->loginAsAdmin(); - $I->amOnPage( '/' ); - $nonce = $I->grabValueFrom( '#test-ajax-nonce' ); + public function test_valid_nonce_returns_200_for_admin(AcceptanceTester $I) + { + $I->loginAsAdmin(); + $I->amOnPage('/'); + $nonce = $I->grabValueFrom('#test-ajax-nonce'); - $I->amOnAdminAjaxPage( [ - 'action' => 'test_ajax_action', - '_ajax_nonce' => $nonce - ] ); - $I->seeResponseCodeIs( 200 ); - $I->canSee( json_encode( [ 'type' => 'priv' ] ) ); - } + $I->amOnAdminAjaxPage([ + 'action' => 'test_ajax_action', + '_ajax_nonce' => $nonce + ]); + $I->seeResponseCodeIs(200); + $I->canSee(json_encode([ 'type' => 'priv' ])); + } } diff --git a/tests/unit/Codeception/Lib/Generator/WPUnitTest.php b/tests/unit/Codeception/Lib/Generator/WPUnitTest.php index a3d1e2c72..ac9f162ec 100644 --- a/tests/unit/Codeception/Lib/Generator/WPUnitTest.php +++ b/tests/unit/Codeception/Lib/Generator/WPUnitTest.php @@ -7,114 +7,122 @@ use tad\Codeception\SnapshotAssertions\SnapshotAssertions; use tad\WPBrowser\Compat\Compatibility; -class WPUnitTest extends \Codeception\Test\Unit { - use WithUopz; - use SnapshotAssertions; - - /** - * A backup of the current PHPUnit Series env var. - * @var array|false|string - */ - protected $phpunitSeriesEnv; - /** - * @var \UnitTester - */ - protected $tester; - - /** - * @var string - */ - private $phpunitVersionPropertyBackup = null; - - private function setPhpUnitSeriesTo( $series ) { - $reflectionClass = new ReflectionClass( Version::class ); - $versionProp = $reflectionClass->getProperty( 'version' ); - $versionProp->setAccessible( true ); - $this->phpunitVersionPropertyBackup = $versionProp->getValue(); - $versionProp->setValue( $series ); - } - - /** - * @after - */ - public function restorePhpunitVersionProperty() { - if ( null === $this->phpunitVersionPropertyBackup ) { - return; - } - $reflectionClass = new ReflectionClass( Version::class ); - $versionProp = $reflectionClass->getProperty( 'version' ); - $versionProp->setAccessible( true ); - $versionProp->setValue( $this->phpunitVersionPropertyBackup ); - $this->phpunitVersionPropertyBackup = null; - } - - /** - * It should scaffold PHPUnit v8 compatible code on series 8 - * - * @test - * @dataProvider phpUnitEq8Series - */ - public function should_scaffold_php_unit_v_8_code_on_series_8( $series ) { - $this->setPhpUnitSeriesTo( '8.0' ); - $settings = [ 'namespace' => 'Acme' ]; - $name = 'SomeClass'; - - $generator = new WPUnit( $settings, $name, WPTestCase::class ); - $code = $generator->produce(); - - $this->assertMatchesCodeSnapshot( $code, 'php' ); - } - - public function phpUnitLt8Series() { - return [ - '5.5' => [ '5.5' ], - '5.5.5' => [ '5.5' ], - '6.2' => [ '6.2' ], - '6.2.3' => [ '6.2' ], - '7.5' => [ '7.5' ], - '7.5.6' => [ '7.5' ], - ]; - } - - /** - * It should scaffold PHPUnit lt 8.0 compatible code on series lt 8 - * - * @test - * @dataProvider phpUnitLt8Series - */ - public function should_scaffold_php_unit_lt_8_0_compatible_code_on_series_lt_8( $series ) { - $this->setPhpUnitSeriesTo( $series ); - $settings = [ 'namespace' => 'Acme' ]; - $name = 'SomeClass'; - - $generator = new WPUnit( $settings, $name, WPTestCase::class ); - $code = $generator->produce(); - - $this->assertMatchesCodeSnapshot( $code, 'php' ); - } - - /** - * It should correctly add the tester property if actor is set in the settings - * - * @test - */ - public function should_correctly_add_the_tester_property_if_actor_is_set_in_the_settings() { - $this->setPhpUnitSeriesTo( '6.0' ); - $settings = [ 'namespace' => 'Acme', 'actor' => 'Fixer' ]; - $name = 'SomeClass'; - - $generator = new WPUnit( $settings, $name, WPTestCase::class ); - $code = $generator->produce(); - - $this->assertMatchesCodeSnapshot( $code, 'php' ); - } - - public function phpUnitEq8Series() { - return [ - '8.0' => [ '8.0' ], - '8.0.4' => [ '8.0.4' ], - '8.1' => [ '8.1' ], - '8.1.6' => [ '8.1.6' ], - ]; - } +class WPUnitTest extends \Codeception\Test\Unit +{ + use WithUopz; + use SnapshotAssertions; + + /** + * A backup of the current PHPUnit Series env var. + * @var array|false|string + */ + protected $phpunitSeriesEnv; + /** + * @var \UnitTester + */ + protected $tester; + + /** + * @var string + */ + private $phpunitVersionPropertyBackup = null; + + private function setPhpUnitSeriesTo($series) + { + $reflectionClass = new ReflectionClass(Version::class); + $versionProp = $reflectionClass->getProperty('version'); + $versionProp->setAccessible(true); + $this->phpunitVersionPropertyBackup = $versionProp->getValue(); + $versionProp->setValue($series); + } + + /** + * @after + */ + public function restorePhpunitVersionProperty() + { + if (null === $this->phpunitVersionPropertyBackup) { + return; + } + $reflectionClass = new ReflectionClass(Version::class); + $versionProp = $reflectionClass->getProperty('version'); + $versionProp->setAccessible(true); + $versionProp->setValue($this->phpunitVersionPropertyBackup); + $this->phpunitVersionPropertyBackup = null; + } + + /** + * It should scaffold PHPUnit v8 compatible code on series 8 + * + * @test + * @dataProvider phpUnitEq8Series + */ + public function should_scaffold_php_unit_v_8_code_on_series_8($series) + { + $this->setPhpUnitSeriesTo('8.0'); + $settings = [ 'namespace' => 'Acme' ]; + $name = 'SomeClass'; + + $generator = new WPUnit($settings, $name, WPTestCase::class); + $code = $generator->produce(); + + $this->assertMatchesCodeSnapshot($code, 'php'); + } + + public function phpUnitLt8Series() + { + return [ + '5.5' => [ '5.5' ], + '5.5.5' => [ '5.5' ], + '6.2' => [ '6.2' ], + '6.2.3' => [ '6.2' ], + '7.5' => [ '7.5' ], + '7.5.6' => [ '7.5' ], + ]; + } + + /** + * It should scaffold PHPUnit lt 8.0 compatible code on series lt 8 + * + * @test + * @dataProvider phpUnitLt8Series + */ + public function should_scaffold_php_unit_lt_8_0_compatible_code_on_series_lt_8($series) + { + $this->setPhpUnitSeriesTo($series); + $settings = [ 'namespace' => 'Acme' ]; + $name = 'SomeClass'; + + $generator = new WPUnit($settings, $name, WPTestCase::class); + $code = $generator->produce(); + + $this->assertMatchesCodeSnapshot($code, 'php'); + } + + /** + * It should correctly add the tester property if actor is set in the settings + * + * @test + */ + public function should_correctly_add_the_tester_property_if_actor_is_set_in_the_settings() + { + $this->setPhpUnitSeriesTo('6.0'); + $settings = [ 'namespace' => 'Acme', 'actor' => 'Fixer' ]; + $name = 'SomeClass'; + + $generator = new WPUnit($settings, $name, WPTestCase::class); + $code = $generator->produce(); + + $this->assertMatchesCodeSnapshot($code, 'php'); + } + + public function phpUnitEq8Series() + { + return [ + '8.0' => [ '8.0' ], + '8.0.4' => [ '8.0.4' ], + '8.1' => [ '8.1' ], + '8.1.6' => [ '8.1.6' ], + ]; + } } diff --git a/tests/wploader_plugin_silent_activation/DoingItRightTest.php b/tests/wploader_plugin_silent_activation/DoingItRightTest.php index bab65c350..53c321932 100644 --- a/tests/wploader_plugin_silent_activation/DoingItRightTest.php +++ b/tests/wploader_plugin_silent_activation/DoingItRightTest.php @@ -1,23 +1,26 @@ assertTrue( is_plugin_active( 'doing-it-right/plugin.php' ) ); - $this->assertEquals( 'activated', get_option( 'doing_it_right_activation' ) ); - } +class DoingItRightTest extends \Codeception\TestCase\WPTestCase +{ + /** + * It should have correctly activated the plugin + * + * @test + */ + public function should_have_correctly_activated_the_plugin() + { + $this->assertTrue(is_plugin_active('doing-it-right/plugin.php')); + $this->assertEquals('activated', get_option('doing_it_right_activation')); + } - /** - * It should correctly load the plugin - * - * @test - */ - public function should_correctly_load_the_plugin() { - global $doing_it_right_plugin_loaded; - $this->assertTrue( $doing_it_right_plugin_loaded ); - } + /** + * It should correctly load the plugin + * + * @test + */ + public function should_correctly_load_the_plugin() + { + global $doing_it_right_plugin_loaded; + $this->assertTrue($doing_it_right_plugin_loaded); + } } diff --git a/tests/wploader_plugin_silent_activation/DoingItWrongPluginOneTest.php b/tests/wploader_plugin_silent_activation/DoingItWrongPluginOneTest.php index 671d64e67..6af5330de 100644 --- a/tests/wploader_plugin_silent_activation/DoingItWrongPluginOneTest.php +++ b/tests/wploader_plugin_silent_activation/DoingItWrongPluginOneTest.php @@ -1,31 +1,35 @@ assertTrue( is_plugin_active( 'doing-it-wrong-1/plugin.php' ) ); - } +class DoingItWrongPluginOneTest extends \Codeception\TestCase\WPTestCase +{ + /** + * It should have activated plugin one + * + * @test + */ + public function should_have_activated_plugin_one() + { + $this->assertTrue(is_plugin_active('doing-it-wrong-1/plugin.php')); + } - /** - * It should not have set the option during the plugin activation - * - * @test - */ - public function should_have_not_set_the_option_during_the_plugin_activation(){ - $this->assertEquals( '', get_option( 'doing_it_wrong_1_activation' ) ); - } + /** + * It should not have set the option during the plugin activation + * + * @test + */ + public function should_have_not_set_the_option_during_the_plugin_activation() + { + $this->assertEquals('', get_option('doing_it_wrong_1_activation')); + } - /** - * It should correctly load the plugin - * - * @test - */ - public function should_correctly_load_the_plugin() { - global $doing_it_wrong_1_plugin_loaded; - $this->assertTrue( $doing_it_wrong_1_plugin_loaded ); - } + /** + * It should correctly load the plugin + * + * @test + */ + public function should_correctly_load_the_plugin() + { + global $doing_it_wrong_1_plugin_loaded; + $this->assertTrue($doing_it_wrong_1_plugin_loaded); + } } diff --git a/tests/wploader_plugin_silent_activation/DoingItWrongPluginTwoTest.php b/tests/wploader_plugin_silent_activation/DoingItWrongPluginTwoTest.php index bc4e0dc5b..f473f007d 100644 --- a/tests/wploader_plugin_silent_activation/DoingItWrongPluginTwoTest.php +++ b/tests/wploader_plugin_silent_activation/DoingItWrongPluginTwoTest.php @@ -1,31 +1,35 @@ assertTrue( is_plugin_active( 'doing-it-wrong-2/plugin.php' ) ); - } +class DoingItWrongPluginTwoTest extends \Codeception\TestCase\WPTestCase +{ + /** + * It should have activated plugin two + * + * @test + */ + public function should_have_activated_plugin_two() + { + $this->assertTrue(is_plugin_active('doing-it-wrong-2/plugin.php')); + } - /** - * It should have not set the option during the plugin activation - * - * @test - */ - public function should_have_set_not_the_option_during_the_plugin_activation() { - $this->assertEquals( '', get_option( 'doing_it_wrong_2_activation' ) ); - } + /** + * It should have not set the option during the plugin activation + * + * @test + */ + public function should_have_set_not_the_option_during_the_plugin_activation() + { + $this->assertEquals('', get_option('doing_it_wrong_2_activation')); + } - /** - * It should correctly load the plugin - * - * @test - */ - public function should_correctly_load_the_plugin() { - global $doing_it_wrong_2_plugin_loaded; - $this->assertTrue( $doing_it_wrong_2_plugin_loaded ); - } + /** + * It should correctly load the plugin + * + * @test + */ + public function should_correctly_load_the_plugin() + { + global $doing_it_wrong_2_plugin_loaded; + $this->assertTrue($doing_it_wrong_2_plugin_loaded); + } } diff --git a/tests/wploadersuite/BeforeAfterMethodsTest.php b/tests/wploadersuite/BeforeAfterMethodsTest.php index d83b24d73..95d9380a1 100644 --- a/tests/wploadersuite/BeforeAfterMethodsTest.php +++ b/tests/wploadersuite/BeforeAfterMethodsTest.php @@ -2,23 +2,28 @@ use PHPUnit\Framework\Assert; -class BeforeAfterMethodsTest extends \Codeception\TestCase\WPTestCase { - private static $staticCanary = true; - private $canary = false; +class BeforeAfterMethodsTest extends \Codeception\TestCase\WPTestCase +{ + private static $staticCanary = true; + private $canary = false; - public function _before() { - $this->canary = true; - } + public function _before() + { + $this->canary = true; + } - public function _after() { - self::$staticCanary = false; - } + public function _after() + { + self::$staticCanary = false; + } - public static function wpTearDownAfterClass() { - Assert::assertFalse( self::$staticCanary ); - } + public static function wpTearDownAfterClass() + { + Assert::assertFalse(self::$staticCanary); + } - public function test_before_method_is_loaded() { - $this->assertTrue( $this->canary ); - } + public function test_before_method_is_loaded() + { + $this->assertTrue($this->canary); + } }