diff --git a/CHANGELOG.md b/CHANGELOG.md index 23b73a504..cdba43a84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] Unreleased +## [4.2.5] 2024-06-26; + +### Changed + +- Updated documentation entry in EndToEnd suite bootstrap file. + ## [4.2.4] 2024-06-06; ### Added @@ -2221,4 +2227,5 @@ Read the [migration guide here](https://wpbrowser.wptestkit.dev/migration/from-v [4.2.1]: https://github.com/lucatume/wp-browser/compare/4.2.0...4.2.1 [4.2.3]: https://github.com/lucatume/wp-browser/compare/4.2.1...4.2.3 [4.2.4]: https://github.com/lucatume/wp-browser/compare/4.2.3...4.2.4 -[unreleased]: https://github.com/lucatume/wp-browser/compare/4.2.4...HEAD +[4.2.5]: https://github.com/lucatume/wp-browser/compare/4.2.4...4.2.5 +[unreleased]: https://github.com/lucatume/wp-browser/compare/4.2.5...HEAD diff --git a/composer.json b/composer.json index 1974572f9..7dd4a581e 100644 --- a/composer.json +++ b/composer.json @@ -67,7 +67,8 @@ }, "autoload-dev": { "psr-4": { - "lucatume\\WPBrowser\\Tests\\": "tests/_support", + "lucatume\\WPBrowser\\Tests\\FSTemplates\\": "tests/_support/FSTemplates", + "lucatume\\WPBrowser\\Tests\\Traits\\": "tests/_support/Traits", "lucatume\\Rector\\": "config/rector/src" } }, diff --git a/src/Project/ContentProject.php b/src/Project/ContentProject.php index f635e4eda..28ebdde44 100644 --- a/src/Project/ContentProject.php +++ b/src/Project/ContentProject.php @@ -115,16 +115,12 @@ public function setup(): void EOT; - $symlinkerConfig = [ - 'wpRootFolder' => '%WORDPRESS_ROOT_DIR%', - 'plugins' => [], - 'themes' => [] - ]; + $symlinkerConfig = [ 'wpRootFolder' => '%WORDPRESS_ROOT_DIR%' ]; if ($this instanceof PluginProject) { - $symlinkerConfig['plugins'][] = '.'; + $symlinkerConfig['plugins'] = ['.']; } elseif ($this instanceof ThemeProject) { - $symlinkerConfig['themes'][] = '.'; + $symlinkerConfig['themes'] = ['.']; } $this->testEnvironment->extensionsEnabled = [ diff --git a/src/Template/Wpbrowser.php b/src/Template/Wpbrowser.php index 84dfafcd9..99e3db8ed 100644 --- a/src/Template/Wpbrowser.php +++ b/src/Template/Wpbrowser.php @@ -295,13 +295,15 @@ private function createEndToEndSuite(ProjectInterface $project): void * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ EOF; $bootstrapPathname = $this->workDir . '/tests/EndToEnd/_bootstrap.php'; diff --git a/src/WordPress/Database/SQLiteDatabase.php b/src/WordPress/Database/SQLiteDatabase.php index 731d53ecb..1e2b0d88b 100644 --- a/src/WordPress/Database/SQLiteDatabase.php +++ b/src/WordPress/Database/SQLiteDatabase.php @@ -255,7 +255,7 @@ public function dump(string $dumpFilePath): void $db = new SQLite3($this->dbPathname); $db->busyTimeout(5000); - $sql = ""; + $sql = "PRAGMA foreign_keys = OFF;\n\n"; $tables = $db->query("SELECT name FROM sqlite_master WHERE type ='table' AND name NOT LIKE 'sqlite_%';"); @@ -270,7 +270,7 @@ public function dump(string $dumpFilePath): void throw new DbException("Could not read table $table[0] from database.", DbException::FAILED_DUMP); } - $sql .= $tableSql . ";\n\n"; + $sql .= "DROP TABLE IF EXISTS $table[0];\n" . $tableSql . ";\n\n"; $rows = $db->query("SELECT * FROM $table[0]"); if ($rows === false) { @@ -308,6 +308,8 @@ public function dump(string $dumpFilePath): void $sql = rtrim($sql, ",") . ";\n\n"; } + $sql .= "PRAGMA foreign_keys = ON\n"; + if (file_put_contents($dumpFilePath, $sql) === false) { throw new DbException("Could not write dump file $dumpFilePath.", DbException::FAILED_DUMP); } diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure__0.snapshot index 680e49321..1103fec01 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure__0.snapshot @@ -169,13 +169,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /EndToEnd/_bootstrap.php <<< diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure_using_default_configuration__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure_using_default_configuration__0.snapshot index 62ce0a039..8f1dd2d72 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure_using_default_configuration__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure_using_default_configuration__0.snapshot @@ -214,13 +214,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /EndToEnd/_bootstrap.php <<< @@ -267,8 +269,8 @@ TEST_TABLE_PREFIX=test_ WORDPRESS_TABLE_PREFIX=wp_ # The URL and domain of the WordPress site used in end-to-end tests. -WORDPRESS_URL=http://localhost:24423 -WORDPRESS_DOMAIN=localhost:24423 +WORDPRESS_URL=http://localhost:28388 +WORDPRESS_DOMAIN=localhost:28388 WORDPRESS_ADMIN_PATH=/wp/wp-admin # The username and password of the administrator user of the WordPress site used in end-to-end tests. @@ -277,10 +279,10 @@ WORDPRESS_ADMIN_PASSWORD=password # The host and port of the ChromeDriver server that will be used in end-to-end tests. CHROMEDRIVER_HOST=localhost -CHROMEDRIVER_PORT=17558 +CHROMEDRIVER_PORT=9649 # The port on which the PHP built-in server will serve the WordPress installation. -BUILTIN_SERVER_PORT=24423 +BUILTIN_SERVER_PORT=28388 # The path to the directory that should be served on localhost, the one containing the wp-config.php file. WORDPRESS_DOCROOT=web diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_child_theme_correctly__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_child_theme_correctly__0.snapshot index 644e13d3b..a400b43d1 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_child_theme_correctly__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_child_theme_correctly__0.snapshot @@ -222,13 +222,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /tests/EndToEnd/_bootstrap.php <<< @@ -270,8 +272,8 @@ TEST_TABLE_PREFIX=test_ WORDPRESS_TABLE_PREFIX=wp_ # The URL and domain of the WordPress site used in end-to-end tests. -WORDPRESS_URL=http://localhost:32347 -WORDPRESS_DOMAIN=localhost:32347 +WORDPRESS_URL=http://localhost:8970 +WORDPRESS_DOMAIN=localhost:8970 WORDPRESS_ADMIN_PATH=/wp-admin # The username and password of the administrator user of the WordPress site used in end-to-end tests. @@ -280,10 +282,10 @@ WORDPRESS_ADMIN_PASSWORD=password # The host and port of the ChromeDriver server that will be used in end-to-end tests. CHROMEDRIVER_HOST=localhost -CHROMEDRIVER_PORT=59028 +CHROMEDRIVER_PORT=43956 # The port on which the PHP built-in server will serve the WordPress installation. -BUILTIN_SERVER_PORT=32347 +BUILTIN_SERVER_PORT=8970 <<< /tests/.env <<< @@ -325,7 +327,6 @@ extensions: DB_FILE: db.sqlite lucatume\WPBrowser\Extension\Symlinker: wpRootFolder: '%WORDPRESS_ROOT_DIR%' - plugins: { } themes: - . commands: diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_multi_site_correctly__1.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_multi_site_correctly__1.snapshot index 39177ae30..e72485b1a 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_multi_site_correctly__1.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_multi_site_correctly__1.snapshot @@ -214,13 +214,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /EndToEnd/_bootstrap.php <<< @@ -267,8 +269,8 @@ TEST_TABLE_PREFIX=test_ WORDPRESS_TABLE_PREFIX=wp_ # The URL and domain of the WordPress site used in end-to-end tests. -WORDPRESS_URL=http://localhost:9035 -WORDPRESS_DOMAIN=localhost:9035 +WORDPRESS_URL=http://localhost:14644 +WORDPRESS_DOMAIN=localhost:14644 WORDPRESS_ADMIN_PATH=/wp-admin # The username and password of the administrator user of the WordPress site used in end-to-end tests. @@ -277,10 +279,10 @@ WORDPRESS_ADMIN_PASSWORD=password # The host and port of the ChromeDriver server that will be used in end-to-end tests. CHROMEDRIVER_HOST=localhost -CHROMEDRIVER_PORT=21043 +CHROMEDRIVER_PORT=17240 # The port on which the PHP built-in server will serve the WordPress installation. -BUILTIN_SERVER_PORT=9035 +BUILTIN_SERVER_PORT=14644 <<< /.env <<< diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file__0.snapshot index dc1230795..b48a1b4d4 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file__0.snapshot @@ -209,13 +209,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /tests/EndToEnd/_bootstrap.php <<< @@ -265,8 +267,8 @@ TEST_TABLE_PREFIX=test_ WORDPRESS_TABLE_PREFIX=wp_ # The URL and domain of the WordPress site used in end-to-end tests. -WORDPRESS_URL=http://localhost:48989 -WORDPRESS_DOMAIN=localhost:48989 +WORDPRESS_URL=http://localhost:27090 +WORDPRESS_DOMAIN=localhost:27090 WORDPRESS_ADMIN_PATH=/wp-admin # The username and password of the administrator user of the WordPress site used in end-to-end tests. @@ -275,10 +277,10 @@ WORDPRESS_ADMIN_PASSWORD=password # The host and port of the ChromeDriver server that will be used in end-to-end tests. CHROMEDRIVER_HOST=localhost -CHROMEDRIVER_PORT=10540 +CHROMEDRIVER_PORT=55678 # The port on which the PHP built-in server will serve the WordPress installation. -BUILTIN_SERVER_PORT=48989 +BUILTIN_SERVER_PORT=27090 <<< /tests/.env <<< @@ -322,7 +324,6 @@ extensions: wpRootFolder: '%WORDPRESS_ROOT_DIR%' plugins: - . - themes: { } commands: - lucatume\WPBrowser\Command\RunOriginal - lucatume\WPBrowser\Command\RunAll diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file_custom__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file_custom__0.snapshot index 77f9d15dd..83c61685d 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file_custom__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file_custom__0.snapshot @@ -174,13 +174,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /tests/EndToEnd/_bootstrap.php <<< diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file__0.snapshot index 745075eca..84bb022ec 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file__0.snapshot @@ -214,13 +214,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /tests/EndToEnd/_bootstrap.php <<< @@ -270,8 +272,8 @@ TEST_TABLE_PREFIX=test_ WORDPRESS_TABLE_PREFIX=wp_ # The URL and domain of the WordPress site used in end-to-end tests. -WORDPRESS_URL=http://localhost:51713 -WORDPRESS_DOMAIN=localhost:51713 +WORDPRESS_URL=http://localhost:45130 +WORDPRESS_DOMAIN=localhost:45130 WORDPRESS_ADMIN_PATH=/wp-admin # The username and password of the administrator user of the WordPress site used in end-to-end tests. @@ -280,10 +282,10 @@ WORDPRESS_ADMIN_PASSWORD=password # The host and port of the ChromeDriver server that will be used in end-to-end tests. CHROMEDRIVER_HOST=localhost -CHROMEDRIVER_PORT=41985 +CHROMEDRIVER_PORT=53682 # The port on which the PHP built-in server will serve the WordPress installation. -BUILTIN_SERVER_PORT=51713 +BUILTIN_SERVER_PORT=45130 <<< /tests/.env <<< @@ -327,7 +329,6 @@ extensions: wpRootFolder: '%WORDPRESS_ROOT_DIR%' plugins: - . - themes: { } commands: - lucatume\WPBrowser\Command\RunOriginal - lucatume\WPBrowser\Command\RunAll diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file_custom__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file_custom__0.snapshot index 0734db2f2..82587e8b3 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file_custom__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file_custom__0.snapshot @@ -174,13 +174,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /tests/EndToEnd/_bootstrap.php <<< diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_single_site_correctly__1.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_single_site_correctly__1.snapshot index a808ee15b..81186b3b8 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_single_site_correctly__1.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_single_site_correctly__1.snapshot @@ -214,13 +214,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /EndToEnd/_bootstrap.php <<< @@ -267,8 +269,8 @@ TEST_TABLE_PREFIX=test_ WORDPRESS_TABLE_PREFIX=wp_ # The URL and domain of the WordPress site used in end-to-end tests. -WORDPRESS_URL=http://localhost:26712 -WORDPRESS_DOMAIN=localhost:26712 +WORDPRESS_URL=http://localhost:23271 +WORDPRESS_DOMAIN=localhost:23271 WORDPRESS_ADMIN_PATH=/wp-admin # The username and password of the administrator user of the WordPress site used in end-to-end tests. @@ -277,10 +279,10 @@ WORDPRESS_ADMIN_PASSWORD=password # The host and port of the ChromeDriver server that will be used in end-to-end tests. CHROMEDRIVER_HOST=localhost -CHROMEDRIVER_PORT=12425 +CHROMEDRIVER_PORT=45511 # The port on which the PHP built-in server will serve the WordPress installation. -BUILTIN_SERVER_PORT=26712 +BUILTIN_SERVER_PORT=23271 <<< /.env <<< diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_correctly__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_correctly__0.snapshot index b8056a07b..f489b8c62 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_correctly__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_correctly__0.snapshot @@ -222,13 +222,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /tests/EndToEnd/_bootstrap.php <<< @@ -270,8 +272,8 @@ TEST_TABLE_PREFIX=test_ WORDPRESS_TABLE_PREFIX=wp_ # The URL and domain of the WordPress site used in end-to-end tests. -WORDPRESS_URL=http://localhost:10603 -WORDPRESS_DOMAIN=localhost:10603 +WORDPRESS_URL=http://localhost:32075 +WORDPRESS_DOMAIN=localhost:32075 WORDPRESS_ADMIN_PATH=/wp-admin # The username and password of the administrator user of the WordPress site used in end-to-end tests. @@ -280,10 +282,10 @@ WORDPRESS_ADMIN_PASSWORD=password # The host and port of the ChromeDriver server that will be used in end-to-end tests. CHROMEDRIVER_HOST=localhost -CHROMEDRIVER_PORT=43861 +CHROMEDRIVER_PORT=26026 # The port on which the PHP built-in server will serve the WordPress installation. -BUILTIN_SERVER_PORT=10603 +BUILTIN_SERVER_PORT=32075 <<< /tests/.env <<< @@ -325,7 +327,6 @@ extensions: DB_FILE: db.sqlite lucatume\WPBrowser\Extension\Symlinker: wpRootFolder: '%WORDPRESS_ROOT_DIR%' - plugins: { } themes: - . commands: diff --git a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_custom_correctly__0.snapshot b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_custom_correctly__0.snapshot index 6cee5d442..adb4948b8 100644 --- a/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_custom_correctly__0.snapshot +++ b/tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_theme_custom_correctly__0.snapshot @@ -189,13 +189,15 @@ class EndToEndTester extends \Codeception\Actor * "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test * and re-created from the dump file(s). * - * You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd ` command - * to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite. + * You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database, + * use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site. + * Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and + * `wp:db:export` commands to import and export the database. * E.g.: - * `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file. - * `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin. - * `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user. - * `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file. + * `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file. + * `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin. + * `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user. + * `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file. */ <<< /tests/EndToEnd/_bootstrap.php <<< diff --git a/tests/unit/lucatume/WPBrowser/Extension/SymlinkerTest.php b/tests/unit/lucatume/WPBrowser/Extension/SymlinkerTest.php index 558388470..aa54a2129 100644 --- a/tests/unit/lucatume/WPBrowser/Extension/SymlinkerTest.php +++ b/tests/unit/lucatume/WPBrowser/Extension/SymlinkerTest.php @@ -2,9 +2,11 @@ namespace unit\lucatume\WPBrowser\Extension; +use Codeception\Codecept; use Codeception\Event\SuiteEvent; use Codeception\Exception\ModuleConfigException; use Codeception\Exception\ModuleException; +use Codeception\Suite; use Codeception\Test\Unit; use lucatume\WPBrowser\Extension\Symlinker; use lucatume\WPBrowser\Tests\Traits\LoopIsolation; @@ -12,12 +14,23 @@ use lucatume\WPBrowser\Utils\Filesystem as FS; use lucatume\WPBrowser\WordPress\Installation; use PHPUnit\Framework\Assert; +use Symfony\Component\EventDispatcher\EventDispatcher; class SymlinkerTest extends Unit { use LoopIsolation; use TmpFilesCleanup; + private function getSuiteEvent(): SuiteEvent + { + if (Codecept::VERSION >= 5) { + return new SuiteEvent(new Suite(new EventDispatcher(), 'test')); + } + + // Codeception 4.x. + return new SuiteEvent(new Suite()); + } + public function test_exists(): void { $symlinker = new Symlinker([ @@ -31,10 +44,11 @@ public function test_throw_if_wp_root_folder_is_not_set(): void { $this->expectException(ModuleConfigException::class); $this->expectExceptionMessage('The `wpRootFolder` configuration parameter must be set.'); + $suiteEvent = $this->getSuiteEvent(); $symlinker = new Symlinker([ ], []); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); } public function test_throw_if_wp_root_folder_does_not_point_to_a_valid_installation(): void @@ -42,12 +56,13 @@ public function test_throw_if_wp_root_folder_does_not_point_to_a_valid_installat $symlinker = new Symlinker([ 'wpRootFolder' => __DIR__, ], []); + $suiteEvent = $this->getSuiteEvent(); $this->expectException(ModuleConfigException::class); $this->expectExceptionMessage('The `wpRootFolder` does not point to a valid WordPress installation.'); - $this->assertInIsolation(static function () use ($symlinker) { - $symlinker->onModuleInit(new SuiteEvent()); + $this->assertInIsolation(static function () use ($symlinker, $suiteEvent) { + $symlinker->onModuleInit($suiteEvent); }); } @@ -55,24 +70,26 @@ public function test_throw_if_plugins_are_not_array(): void { $this->expectException(ModuleConfigException::class); $this->expectExceptionMessage('The `plugins` configuration parameter must be an array.'); + $suiteEvent = $this->getSuiteEvent(); $symlinker = new Symlinker([ 'wpRootFolder' => __DIR__, 'plugins' => 'not-an-array', ], []); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); } public function test_throw_if_themes_are_not_array(): void { $this->expectException(ModuleConfigException::class); $this->expectExceptionMessage('The `themes` configuration parameter must be an array.'); + $suiteEvent = $this->getSuiteEvent(); $symlinker = new Symlinker([ 'wpRootFolder' => __DIR__, 'themes' => 'not-an-array', ], []); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); } public function test_without_plugins_or_themes(): void @@ -80,18 +97,19 @@ public function test_without_plugins_or_themes(): void $workingDir = FS::tmpDir('symlinker_'); $wpRoot = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); $symlinker = new Symlinker([ 'wpRootFolder' => $wpRoot, ], []); - $this->assertInIsolation(static function () use ($symlinker, $workingDir) { + $this->assertInIsolation(static function () use ($symlinker, $workingDir, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); - $symlinker->onModuleInit(new SuiteEvent()); - $symlinker->afterSuite(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); + $symlinker->afterSuite($suiteEvent); }); } @@ -107,7 +125,6 @@ public function test_throws_if_plugin_file_does_not_exist(): void $this->expectException(ModuleConfigException::class); $this->expectExceptionMessage('Plugin file not-a-file/plugin.php does not exist.'); - $symlinker = new Symlinker([ 'wpRootFolder' => $wpRoot, 'plugins' => [ @@ -202,8 +219,9 @@ function theme_2_some_function() { ]); $wpRoot = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); - $this->assertInIsolation(static function () use ($workingDir, $wpRoot) { + $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); @@ -230,7 +248,7 @@ function theme_2_some_function() { Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -241,7 +259,7 @@ function theme_2_some_function() { Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->afterSuite(new SuiteEvent()); + $symlinker->afterSuite($suiteEvent); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -320,8 +338,9 @@ function theme_2_some_function() { ]); $wpRoot = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); - $this->assertInIsolation(static function () use ($workingDir, $wpRoot) { + $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); @@ -348,7 +367,7 @@ function theme_2_some_function() { Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -359,7 +378,7 @@ function theme_2_some_function() { Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->afterSuite(new SuiteEvent()); + $symlinker->afterSuite($suiteEvent); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -438,8 +457,9 @@ function theme_2_some_function() { ]); $wpRoot = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); - $this->assertInIsolation(static function () use ($workingDir, $wpRoot) { + $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); @@ -465,7 +485,7 @@ function theme_2_some_function() { Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -476,7 +496,7 @@ function theme_2_some_function() { Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->afterSuite(new SuiteEvent()); + $symlinker->afterSuite($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -555,8 +575,9 @@ function theme_2_some_function() { ]); $wpRoot = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); - $this->assertInIsolation(static function () use ($workingDir, $wpRoot) { + $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); @@ -583,7 +604,7 @@ function theme_2_some_function() { Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileDoesNotExist($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -594,7 +615,7 @@ function theme_2_some_function() { Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->afterSuite(new SuiteEvent()); + $symlinker->afterSuite($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -673,8 +694,9 @@ function theme_2_some_function() { ]); $wpRoot = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); - $this->assertInIsolation(static function () use ($workingDir, $wpRoot) { + $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); @@ -710,7 +732,7 @@ function theme_2_some_function() { Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -721,7 +743,7 @@ function theme_2_some_function() { Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/index.php'); Assert::assertFileExists($wpRoot . '/wp-content/themes/theme-2/functions.php'); - $symlinker->afterSuite(new SuiteEvent()); + $symlinker->afterSuite($suiteEvent); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-1/plugin-1.php'); Assert::assertFileExists($wpRoot . '/wp-content/plugins/plugin-2/main.php'); @@ -769,13 +791,14 @@ function activate_plugin_2(){ $wpRoot = FS::tmpDir('symlinker_'); $otherDir = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); $this->expectException(ModuleException::class); $this->expectExceptionMessage( "Could not symlink plugin $workingDir/vendor/acme/plugin-2 to $wpRoot/wp-content/plugins/plugin-2: link already exists and target is $otherDir." ); - $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $otherDir) { + $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $otherDir, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); @@ -796,7 +819,7 @@ function activate_plugin_2(){ throw new \RuntimeException('Could not create symlinks in ' . $wpRoot); } - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); }); } @@ -811,8 +834,9 @@ function plugin_1_canary() {} ]); $wpRoot = FS::tmpDir('symlinker_'); Installation::scaffold($wpRoot); + $suiteEvent = $this->getSuiteEvent(); - $this->assertInIsolation(static function () use ($workingDir, $wpRoot) { + $this->assertInIsolation(static function () use ($workingDir, $wpRoot, $suiteEvent) { chdir($workingDir); Assert::assertSame($workingDir, getcwd()); @@ -828,7 +852,7 @@ function plugin_1_canary() {} Assert::assertFileDoesNotExist($wpRoot . "/wp-content/plugins/{$workDirBasename}/plugin.php"); - $symlinker->onModuleInit(new SuiteEvent()); + $symlinker->onModuleInit($suiteEvent); Assert::assertFileExists($wpRoot . "/wp-content/plugins/{$workDirBasename}/plugin.php"); Assert::assertTrue(is_link($wpRoot . "/wp-content/plugins/{$workDirBasename}"));