Skip to content

Commit 7826284

Browse files
committed
fix(Wpbrowser) update default setup documentation
Reference correct commands, ensure SQLite export drops tables before creating them.
1 parent ec51c85 commit 7826284

13 files changed

+128
-102
lines changed

src/Template/Wpbrowser.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,15 @@ private function createEndToEndSuite(ProjectInterface $project): void
295295
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
296296
* and re-created from the dump file(s).
297297
*
298-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
299-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
298+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
299+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
300+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
301+
* `wp:db:export` commands to import and export the database.
300302
* E.g.:
301-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
302-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
303-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
304-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
303+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
304+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
305+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
306+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
305307
*/
306308
EOF;
307309
$bootstrapPathname = $this->workDir . '/tests/EndToEnd/_bootstrap.php';

src/WordPress/Database/SQLiteDatabase.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function dump(string $dumpFilePath): void
255255
$db = new SQLite3($this->dbPathname);
256256
$db->busyTimeout(5000);
257257

258-
$sql = "";
258+
$sql = "PRAGMA foreign_keys = OFF;\n\n";
259259

260260
$tables = $db->query("SELECT name FROM sqlite_master WHERE type ='table' AND name NOT LIKE 'sqlite_%';");
261261

@@ -270,7 +270,7 @@ public function dump(string $dumpFilePath): void
270270
throw new DbException("Could not read table $table[0] from database.", DbException::FAILED_DUMP);
271271
}
272272

273-
$sql .= $tableSql . ";\n\n";
273+
$sql .= "DROP TABLE IF EXISTS $table[0];\n" . $tableSql . ";\n\n";
274274
$rows = $db->query("SELECT * FROM $table[0]");
275275

276276
if ($rows === false) {
@@ -308,6 +308,8 @@ public function dump(string $dumpFilePath): void
308308
$sql = rtrim($sql, ",") . ";\n\n";
309309
}
310310

311+
$sql .= "PRAGMA foreign_keys = ON\n";
312+
311313
if (file_put_contents($dumpFilePath, $sql) === false) {
312314
throw new DbException("Could not write dump file $dumpFilePath.", DbException::FAILED_DUMP);
313315
}

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure__0.snapshot

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,15 @@ class EndToEndTester extends \Codeception\Actor
169169
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
170170
* and re-created from the dump file(s).
171171
*
172-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
173-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
172+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
173+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
174+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
175+
* `wp:db:export` commands to import and export the database.
174176
* E.g.:
175-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
176-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
177-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
178-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
177+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
178+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
179+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
180+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
179181
*/
180182
<<< /EndToEnd/_bootstrap.php <<<
181183

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_correctly_on_site_with_non_default_structure_using_default_configuration__0.snapshot

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,15 @@ class EndToEndTester extends \Codeception\Actor
214214
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
215215
* and re-created from the dump file(s).
216216
*
217-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
218-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
217+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
218+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
219+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
220+
* `wp:db:export` commands to import and export the database.
219221
* E.g.:
220-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
221-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
222-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
223-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
222+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
223+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
224+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
225+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
224226
*/
225227
<<< /EndToEnd/_bootstrap.php <<<
226228

@@ -267,8 +269,8 @@ TEST_TABLE_PREFIX=test_
267269
WORDPRESS_TABLE_PREFIX=wp_
268270

269271
# The URL and domain of the WordPress site used in end-to-end tests.
270-
WORDPRESS_URL=http://localhost:24423
271-
WORDPRESS_DOMAIN=localhost:24423
272+
WORDPRESS_URL=http://localhost:28388
273+
WORDPRESS_DOMAIN=localhost:28388
272274
WORDPRESS_ADMIN_PATH=/wp/wp-admin
273275

274276
# 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
277279

278280
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
279281
CHROMEDRIVER_HOST=localhost
280-
CHROMEDRIVER_PORT=17558
282+
CHROMEDRIVER_PORT=9649
281283

282284
# The port on which the PHP built-in server will serve the WordPress installation.
283-
BUILTIN_SERVER_PORT=24423
285+
BUILTIN_SERVER_PORT=28388
284286

285287
# The path to the directory that should be served on localhost, the one containing the wp-config.php file.
286288
WORDPRESS_DOCROOT=web

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_child_theme_correctly__0.snapshot

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,15 @@ class EndToEndTester extends \Codeception\Actor
222222
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
223223
* and re-created from the dump file(s).
224224
*
225-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
226-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
225+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
226+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
227+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
228+
* `wp:db:export` commands to import and export the database.
227229
* E.g.:
228-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
229-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
230-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
231-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
230+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
231+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
232+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
233+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
232234
*/
233235
<<< /tests/EndToEnd/_bootstrap.php <<<
234236

@@ -270,8 +272,8 @@ TEST_TABLE_PREFIX=test_
270272
WORDPRESS_TABLE_PREFIX=wp_
271273

272274
# The URL and domain of the WordPress site used in end-to-end tests.
273-
WORDPRESS_URL=http://localhost:32347
274-
WORDPRESS_DOMAIN=localhost:32347
275+
WORDPRESS_URL=http://localhost:47453
276+
WORDPRESS_DOMAIN=localhost:47453
275277
WORDPRESS_ADMIN_PATH=/wp-admin
276278

277279
# 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
280282

281283
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
282284
CHROMEDRIVER_HOST=localhost
283-
CHROMEDRIVER_PORT=59028
285+
CHROMEDRIVER_PORT=43984
284286

285287
# The port on which the PHP built-in server will serve the WordPress installation.
286-
BUILTIN_SERVER_PORT=32347
288+
BUILTIN_SERVER_PORT=47453
287289

288290
<<< /tests/.env <<<
289291

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_multi_site_correctly__1.snapshot

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,15 @@ class EndToEndTester extends \Codeception\Actor
214214
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
215215
* and re-created from the dump file(s).
216216
*
217-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
218-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
217+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
218+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
219+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
220+
* `wp:db:export` commands to import and export the database.
219221
* E.g.:
220-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
221-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
222-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
223-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
222+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
223+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
224+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
225+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
224226
*/
225227
<<< /EndToEnd/_bootstrap.php <<<
226228

@@ -267,8 +269,8 @@ TEST_TABLE_PREFIX=test_
267269
WORDPRESS_TABLE_PREFIX=wp_
268270

269271
# The URL and domain of the WordPress site used in end-to-end tests.
270-
WORDPRESS_URL=http://localhost:9035
271-
WORDPRESS_DOMAIN=localhost:9035
272+
WORDPRESS_URL=http://localhost:14644
273+
WORDPRESS_DOMAIN=localhost:14644
272274
WORDPRESS_ADMIN_PATH=/wp-admin
273275

274276
# 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
277279

278280
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
279281
CHROMEDRIVER_HOST=localhost
280-
CHROMEDRIVER_PORT=21043
282+
CHROMEDRIVER_PORT=17240
281283

282284
# The port on which the PHP built-in server will serve the WordPress installation.
283-
BUILTIN_SERVER_PORT=9035
285+
BUILTIN_SERVER_PORT=14644
284286

285287
<<< /.env <<<
286288

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file__0.snapshot

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,15 @@ class EndToEndTester extends \Codeception\Actor
209209
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
210210
* and re-created from the dump file(s).
211211
*
212-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
213-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
212+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
213+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
214+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
215+
* `wp:db:export` commands to import and export the database.
214216
* E.g.:
215-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
216-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
217-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
218-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
217+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
218+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
219+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
220+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
219221
*/
220222
<<< /tests/EndToEnd/_bootstrap.php <<<
221223

@@ -265,8 +267,8 @@ TEST_TABLE_PREFIX=test_
265267
WORDPRESS_TABLE_PREFIX=wp_
266268

267269
# The URL and domain of the WordPress site used in end-to-end tests.
268-
WORDPRESS_URL=http://localhost:48989
269-
WORDPRESS_DOMAIN=localhost:48989
270+
WORDPRESS_URL=http://localhost:42934
271+
WORDPRESS_DOMAIN=localhost:42934
270272
WORDPRESS_ADMIN_PATH=/wp-admin
271273

272274
# 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
275277

276278
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
277279
CHROMEDRIVER_HOST=localhost
278-
CHROMEDRIVER_PORT=10540
280+
CHROMEDRIVER_PORT=44670
279281

280282
# The port on which the PHP built-in server will serve the WordPress installation.
281-
BUILTIN_SERVER_PORT=48989
283+
BUILTIN_SERVER_PORT=42934
282284

283285
<<< /tests/.env <<<
284286

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_non_plugin_php_file_custom__0.snapshot

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@ class EndToEndTester extends \Codeception\Actor
174174
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
175175
* and re-created from the dump file(s).
176176
*
177-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
178-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
177+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
178+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
179+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
180+
* `wp:db:export` commands to import and export the database.
179181
* E.g.:
180-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
181-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
182-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
183-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
182+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
183+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
184+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
185+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
184186
*/
185187
<<< /tests/EndToEnd/_bootstrap.php <<<
186188

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__should_scaffold_for_plugin_with_plugin_php_file__0.snapshot

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,15 @@ class EndToEndTester extends \Codeception\Actor
214214
* "modules.config.WPDb.dump" setting in the suite configuration file. The database will be dropped after each test
215215
* and re-created from the dump file(s).
216216
*
217-
* You can modify and create new dump files using the `vendor/bin/codecept wp:cli EndToEnd <wp-cli command>` command
218-
* to run WP-CLI commands on the WordPress site and database used by the EndToEnd suite.
217+
* You can modify and create new dump files using WP-CLI or by operating directly on the WordPress site and database,
218+
* use the `vendor/bin/codecept dev:info` command to know the URL to the WordPress site.
219+
* Note that WP-CLI will not natively handle SQLite databases, so you will need to use the `wp:db:import` and
220+
* `wp:db:export` commands to import and export the database.
219221
* E.g.:
220-
* `vendor/bin/codecept wp:cli EndToEnd db import tests/Support/Data/dump.sql` to load dump file.
221-
* `vendor/bin/codecept wp:cli EndToEnd plugin activate woocommerce` to activate the WooCommerce plugin.
222-
* `vendor/bin/codecept wp:cli EndToEnd user create alice alice@example.com --role=administrator` to create a new user.
223-
* `vendor/bin/codecept wp:cli EndToEnd db export tests/Support/Data/dump.sql` to update the dump file.
222+
* `vendor/bin/codecept wp:db:import tests/_wordpress tests/Support/Data/dump.sql` to load dump file.
223+
* `wp --path=tests/_wordpress plugin activate woocommerce` to activate the WooCommerce plugin.
224+
* `wp --path=tests/_wordpress user create alice alice@example.com --role=administrator` to create a new user.
225+
* `vendor/bin/codecept wp:db:export tests/_wordpress tests/Support/Data/dump.sql` to update the dump file.
224226
*/
225227
<<< /tests/EndToEnd/_bootstrap.php <<<
226228

@@ -270,8 +272,8 @@ TEST_TABLE_PREFIX=test_
270272
WORDPRESS_TABLE_PREFIX=wp_
271273

272274
# The URL and domain of the WordPress site used in end-to-end tests.
273-
WORDPRESS_URL=http://localhost:51713
274-
WORDPRESS_DOMAIN=localhost:51713
275+
WORDPRESS_URL=http://localhost:16769
276+
WORDPRESS_DOMAIN=localhost:16769
275277
WORDPRESS_ADMIN_PATH=/wp-admin
276278

277279
# 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
280282

281283
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
282284
CHROMEDRIVER_HOST=localhost
283-
CHROMEDRIVER_PORT=41985
285+
CHROMEDRIVER_PORT=20529
284286

285287
# The port on which the PHP built-in server will serve the WordPress installation.
286-
BUILTIN_SERVER_PORT=51713
288+
BUILTIN_SERVER_PORT=16769
287289

288290
<<< /tests/.env <<<
289291

0 commit comments

Comments
 (0)