Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into v4-phpunit-gte-10-s…
Browse files Browse the repository at this point in the history
…upport
  • Loading branch information
lucatume committed Jul 17, 2024
2 parents 205d48d + 442e488 commit 7d02da2
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 143 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down
10 changes: 3 additions & 7 deletions src/Project/ContentProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
14 changes: 8 additions & 6 deletions src/Template/Wpbrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wp-cli command>` 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 [email protected] --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 [email protected] --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';
Expand Down
6 changes: 4 additions & 2 deletions src/WordPress/Database/SQLiteDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_%';");

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wp-cli command>` 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 [email protected] --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 [email protected] --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 <<<

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wp-cli command>` 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 [email protected] --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 [email protected] --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 <<<

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wp-cli command>` 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 [email protected] --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 [email protected] --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 <<<

Expand Down Expand Up @@ -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.
Expand All @@ -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 <<<

Expand Down Expand Up @@ -325,7 +327,6 @@ extensions:
DB_FILE: db.sqlite
lucatume\WPBrowser\Extension\Symlinker:
wpRootFolder: '%WORDPRESS_ROOT_DIR%'
plugins: { }
themes:
- .
commands:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wp-cli command>` 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 [email protected] --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 [email protected] --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 <<<

Expand Down Expand Up @@ -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.
Expand All @@ -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 <<<

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wp-cli command>` 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 [email protected] --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 [email protected] --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 <<<

Expand Down Expand Up @@ -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.
Expand All @@ -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 <<<

Expand Down Expand Up @@ -322,7 +324,6 @@ extensions:
wpRootFolder: '%WORDPRESS_ROOT_DIR%'
plugins:
- .
themes: { }
commands:
- lucatume\WPBrowser\Command\RunOriginal
- lucatume\WPBrowser\Command\RunAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wp-cli command>` 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 [email protected] --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 [email protected] --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 <<<

Expand Down
Loading

0 comments on commit 7d02da2

Please sign in to comment.