Skip to content

Commit 8023fe6

Browse files
authored
Merge pull request #711 from lucatume/v35-wrap-710
v35 wrap 710
2 parents f2d7c04 + 7c2a3ce commit 8023fe6

16 files changed

+82
-63
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [unreleased] Unreleased
66

7+
### Changed
8+
9+
- Update init template to scaffold dump file path and example tests correctly (thanks @tarecord).
10+
711
## [3.5.4] 2024-03-19;
812

913
### Fixed

src/Project/PluginProject.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace lucatume\WPBrowser\Project;
44

5+
use Codeception\Codecept;
56
use lucatume\WPBrowser\Exceptions\InvalidArgumentException;
67
use lucatume\WPBrowser\Exceptions\RuntimeException;
78
use lucatume\WPBrowser\Process\Loop;
89
use lucatume\WPBrowser\Process\ProcessException;
910
use lucatume\WPBrowser\Process\WorkerException;
10-
use lucatume\WPBrowser\TestCase\WPTestCase;
1111
use lucatume\WPBrowser\Utils\Filesystem as FS;
1212
use lucatume\WPBrowser\Utils\Strings;
1313
use lucatume\WPBrowser\WordPress\CodeExecution\CodeExecutionFactory;
@@ -128,9 +128,11 @@ public function activate(string $wpRootDir, int $serverLocalhostPort): bool
128128
$message = $activationResult->getMessage();
129129
$this->sayWarning('Could not activate plugin: ' . $message);
130130
$this->say($activationResult->getFile() . ":" . $activationResult->getLine());
131+
// @phpstan-ignore-next-line
132+
$dumpPath = Codecept::VERSION >= 5 ? 'tests/Support/Data/dump.sql' : 'tests/_data/dump.sql';
131133
$this->say('This might happen because the plugin has unmet dependencies; wp-browser configuration ' .
132134
'will continue, but you will need to manually activate the plugin and update the dump in ' .
133-
'tests/Support/Data/dump.sql.');
135+
$dumpPath);
134136
return false;
135137
}
136138

@@ -141,13 +143,15 @@ public function activate(string $wpRootDir, int $serverLocalhostPort): bool
141143

142144
protected function scaffoldEndToEndActivationCest(): void
143145
{
146+
// @phpstan-ignore-next-line
147+
$testerTrait = Codecept::VERSION >= 5 ? 'Tests\Support\EndToEndTester' : 'EndToEndTester';
144148
$cestCode = Strings::renderString(
145149
<<<EOT
146150
<?php
147151
148152
namespace Tests\\EndToEnd;
149153
150-
use Tests\\Support\\EndToEndTester;
154+
use {$testerTrait};
151155
152156
class ActivationCest
153157
{

src/Project/SiteProject.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace lucatume\WPBrowser\Project;
44

5+
use Codeception\Codecept;
56
use Codeception\InitTemplate;
67
use lucatume\WPBrowser\Command\ChromedriverUpdate;
78
use lucatume\WPBrowser\Command\DevInfo;
@@ -197,12 +198,14 @@ private function getName(): string
197198

198199
private function scaffoldEndToEndActivationCest(): void
199200
{
201+
// @phpstan-ignore-next-line
202+
$testerTrait = Codecept::VERSION >= 5 ? 'Tests\Support\EndToEndTester' : 'EndToEndTester';
200203
$cestCode = <<< EOT
201204
<?php
202205
203206
namespace Tests\EndToEnd;
204207
205-
use Tests\Support\EndToEndTester;
208+
use $testerTrait;
206209
207210
class ActivationCest
208211
{

src/Project/ThemeProject.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace lucatume\WPBrowser\Project;
44

5+
use Codeception\Codecept;
56
use lucatume\WPBrowser\Exceptions\InvalidArgumentException;
67
use lucatume\WPBrowser\Exceptions\RuntimeException;
78
use lucatume\WPBrowser\Process\Loop;
@@ -114,11 +115,13 @@ public function activate(string $wpRootDir, int $serverLocalhostPort): bool
114115
$switchTheme = $codeExec->toSwitchTheme($this->basename, false);
115116
$activationResult = Loop::executeClosure($switchTheme)->getReturnValue();
116117
if ($activationResult instanceof Throwable) {
118+
// @phpstan-ignore-next-line
119+
$dumpPath = Codecept::VERSION >= 5 ? 'tests/Support/Data/dump.sql' : 'tests/_data/dump.sql';
117120
$message = $activationResult->getMessage();
118121
$this->sayWarning('Could not activate theme: ' . $message);
119122
$this->say('This might happen because the theme has unmet dependencies; wp-browser configuration ' .
120123
'will continue, but you will need to manually activate the theme and update the dump in ' .
121-
'tests/Support/Data/dump.sql.');
124+
$dumpPath);
122125
return false;
123126
}
124127

@@ -129,13 +132,15 @@ public function activate(string $wpRootDir, int $serverLocalhostPort): bool
129132

130133
protected function scaffoldEndToEndActivationCest(): void
131134
{
135+
// @phpstan-ignore-next-line
136+
$testerTrait = Codecept::VERSION >= 5 ? 'Tests\Support\EndToEndTester' : 'EndToEndTester';
132137
$cestCode = Strings::renderString(
133138
<<<EOT
134139
<?php
135140
136141
namespace Tests\\EndToEnd;
137142
138-
use Tests\\Support\\EndToEndTester;
143+
use {$testerTrait};
139144
140145
class ActivationCest
141146
{

src/Template/Wpbrowser.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace lucatume\WPBrowser\Template;
44

5+
use Codeception\Codecept;
56
use Codeception\Extension\RunFailed;
67
use Codeception\Template\Bootstrap;
78
use lucatume\WPBrowser\Command\DbExport;
@@ -220,6 +221,8 @@ private function createEnvFile(): void
220221

221222
private function createEndToEndSuite(ProjectInterface $project): void
222223
{
224+
// @phpstan-ignore-next-line
225+
$dumpFilePath = Codecept::VERSION >= 5 ? 'tests/Support/Data/dump.sql' : 'tests/_data/dump.sql';
223226
$suiteConfig = <<<EOF
224227
# Integration suite configuration
225228
#
@@ -255,7 +258,7 @@ private function createEndToEndSuite(ProjectInterface $project): void
255258
- "--no-sandbox"
256259
lucatume\WPBrowser\Module\WPDb:
257260
dbUrl: '%WORDPRESS_DB_URL%'
258-
dump: 'tests/Support/Data/dump.sql'
261+
dump: '{$dumpFilePath}'
259262
populate: true
260263
cleanup: true
261264
reconnect: false

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__3.5__should_scaffold_for_child_theme_correctly__0.snapshot

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ modules:
3333
- "--no-sandbox"
3434
lucatume\WPBrowser\Module\WPDb:
3535
dbUrl: '%WORDPRESS_DB_URL%'
36-
dump: 'tests/Support/Data/dump.sql'
36+
dump: 'tests/_data/dump.sql'
3737
populate: true
3838
cleanup: true
3939
reconnect: false
@@ -242,7 +242,7 @@ modules:
242242

243243
namespace Tests\EndToEnd;
244244

245-
use Tests\Support\EndToEndTester;
245+
use EndToEndTester;
246246

247247
class ActivationCest
248248
{
@@ -275,19 +275,19 @@ TEST_TABLE_PREFIX=test_
275275
WORDPRESS_TABLE_PREFIX=wp_
276276

277277
# The URL and domain of the WordPress site used in end-to-end tests.
278-
WORDPRESS_URL=http://localhost:41251
279-
WORDPRESS_DOMAIN=localhost:41251
278+
WORDPRESS_URL=http://localhost:35409
279+
WORDPRESS_DOMAIN=localhost:35409
280280

281281
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
282282
WORDPRESS_ADMIN_USER=admin
283283
WORDPRESS_ADMIN_PASSWORD=password
284284

285285
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
286286
CHROMEDRIVER_HOST=localhost
287-
CHROMEDRIVER_PORT=29174
287+
CHROMEDRIVER_PORT=20606
288288

289289
# The port on which the PHP built-in server will serve the WordPress installation.
290-
BUILTIN_SERVER_PORT=41251
290+
BUILTIN_SERVER_PORT=35409
291291

292292
<<< /tests/.env <<<
293293

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__3.5__should_scaffold_for_multi_site_correctly__0.snapshot

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ modules:
3333
- "--no-sandbox"
3434
lucatume\WPBrowser\Module\WPDb:
3535
dbUrl: '%WORDPRESS_DB_URL%'
36-
dump: 'tests/Support/Data/dump.sql'
36+
dump: 'tests/_data/dump.sql'
3737
populate: true
3838
cleanup: true
3939
reconnect: false
@@ -247,7 +247,7 @@ modules:
247247

248248
namespace Tests\EndToEnd;
249249

250-
use Tests\Support\EndToEndTester;
250+
use EndToEndTester;
251251

252252
class ActivationCest
253253
{
@@ -285,19 +285,19 @@ TEST_TABLE_PREFIX=test_
285285
WORDPRESS_TABLE_PREFIX=wp_
286286

287287
# The URL and domain of the WordPress site used in end-to-end tests.
288-
WORDPRESS_URL=http://localhost:9750
289-
WORDPRESS_DOMAIN=localhost:9750
288+
WORDPRESS_URL=http://localhost:37987
289+
WORDPRESS_DOMAIN=localhost:37987
290290

291291
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
292292
WORDPRESS_ADMIN_USER=admin
293293
WORDPRESS_ADMIN_PASSWORD=password
294294

295295
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
296296
CHROMEDRIVER_HOST=localhost
297-
CHROMEDRIVER_PORT=51597
297+
CHROMEDRIVER_PORT=54870
298298

299299
# The port on which the PHP built-in server will serve the WordPress installation.
300-
BUILTIN_SERVER_PORT=9750
300+
BUILTIN_SERVER_PORT=37987
301301

302302
<<< /.env <<<
303303

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__3.5__should_scaffold_for_plugin_with_non_plugin_php_file__0.snapshot

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ modules:
3333
- "--no-sandbox"
3434
lucatume\WPBrowser\Module\WPDb:
3535
dbUrl: '%WORDPRESS_DB_URL%'
36-
dump: 'tests/Support/Data/dump.sql'
36+
dump: 'tests/_data/dump.sql'
3737
populate: true
3838
cleanup: true
3939
reconnect: false
@@ -242,7 +242,7 @@ modules:
242242

243243
namespace Tests\EndToEnd;
244244

245-
use Tests\Support\EndToEndTester;
245+
use EndToEndTester;
246246

247247
class ActivationCest
248248
{
@@ -283,19 +283,19 @@ TEST_TABLE_PREFIX=test_
283283
WORDPRESS_TABLE_PREFIX=wp_
284284

285285
# The URL and domain of the WordPress site used in end-to-end tests.
286-
WORDPRESS_URL=http://localhost:16145
287-
WORDPRESS_DOMAIN=localhost:16145
286+
WORDPRESS_URL=http://localhost:18237
287+
WORDPRESS_DOMAIN=localhost:18237
288288

289289
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
290290
WORDPRESS_ADMIN_USER=admin
291291
WORDPRESS_ADMIN_PASSWORD=password
292292

293293
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
294294
CHROMEDRIVER_HOST=localhost
295-
CHROMEDRIVER_PORT=50293
295+
CHROMEDRIVER_PORT=63427
296296

297297
# The port on which the PHP built-in server will serve the WordPress installation.
298-
BUILTIN_SERVER_PORT=16145
298+
BUILTIN_SERVER_PORT=18237
299299

300300
<<< /tests/.env <<<
301301

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__3.5__should_scaffold_for_plugin_with_non_plugin_php_file_custom__0.snapshot

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ modules:
3838
- "--no-sandbox"
3939
lucatume\WPBrowser\Module\WPDb:
4040
dbUrl: '%WORDPRESS_DB_URL%'
41-
dump: 'tests/Support/Data/dump.sql'
41+
dump: 'tests/_data/dump.sql'
4242
populate: true
4343
cleanup: true
4444
reconnect: false
@@ -247,7 +247,7 @@ modules:
247247

248248
namespace Tests\EndToEnd;
249249

250-
use Tests\Support\EndToEndTester;
250+
use EndToEndTester;
251251

252252
class ActivationCest
253253
{
@@ -288,19 +288,19 @@ TEST_TABLE_PREFIX=test_
288288
WORDPRESS_TABLE_PREFIX=wp_
289289

290290
# The URL and domain of the WordPress site used in end-to-end tests.
291-
WORDPRESS_URL=http://localhost:40096
292-
WORDPRESS_DOMAIN=localhost:40096
291+
WORDPRESS_URL=http://localhost:38047
292+
WORDPRESS_DOMAIN=localhost:38047
293293

294294
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
295295
WORDPRESS_ADMIN_USER=admin
296296
WORDPRESS_ADMIN_PASSWORD=password
297297

298298
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
299299
CHROMEDRIVER_HOST=localhost
300-
CHROMEDRIVER_PORT=9351
300+
CHROMEDRIVER_PORT=56902
301301

302302
# The port on which the PHP built-in server will serve the WordPress installation.
303-
BUILTIN_SERVER_PORT=40096
303+
BUILTIN_SERVER_PORT=38047
304304

305305
<<< /tests/.env <<<
306306

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__3.5__should_scaffold_for_plugin_with_plugin_php_file__0.snapshot

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ modules:
3838
- "--no-sandbox"
3939
lucatume\WPBrowser\Module\WPDb:
4040
dbUrl: '%WORDPRESS_DB_URL%'
41-
dump: 'tests/Support/Data/dump.sql'
41+
dump: 'tests/_data/dump.sql'
4242
populate: true
4343
cleanup: true
4444
reconnect: false
@@ -247,7 +247,7 @@ modules:
247247

248248
namespace Tests\EndToEnd;
249249

250-
use Tests\Support\EndToEndTester;
250+
use EndToEndTester;
251251

252252
class ActivationCest
253253
{
@@ -288,19 +288,19 @@ TEST_TABLE_PREFIX=test_
288288
WORDPRESS_TABLE_PREFIX=wp_
289289

290290
# The URL and domain of the WordPress site used in end-to-end tests.
291-
WORDPRESS_URL=http://localhost:61506
292-
WORDPRESS_DOMAIN=localhost:61506
291+
WORDPRESS_URL=http://localhost:18285
292+
WORDPRESS_DOMAIN=localhost:18285
293293

294294
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
295295
WORDPRESS_ADMIN_USER=admin
296296
WORDPRESS_ADMIN_PASSWORD=password
297297

298298
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
299299
CHROMEDRIVER_HOST=localhost
300-
CHROMEDRIVER_PORT=2860
300+
CHROMEDRIVER_PORT=28492
301301

302302
# The port on which the PHP built-in server will serve the WordPress installation.
303-
BUILTIN_SERVER_PORT=61506
303+
BUILTIN_SERVER_PORT=18285
304304

305305
<<< /tests/.env <<<
306306

tests/unit/Codeception/Template/__snapshots__/WpbrowserTest__3.5__should_scaffold_for_plugin_with_plugin_php_file_custom__0.snapshot

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ modules:
3838
- "--no-sandbox"
3939
lucatume\WPBrowser\Module\WPDb:
4040
dbUrl: '%WORDPRESS_DB_URL%'
41-
dump: 'tests/Support/Data/dump.sql'
41+
dump: 'tests/_data/dump.sql'
4242
populate: true
4343
cleanup: true
4444
reconnect: false
@@ -247,7 +247,7 @@ modules:
247247

248248
namespace Tests\EndToEnd;
249249

250-
use Tests\Support\EndToEndTester;
250+
use EndToEndTester;
251251

252252
class ActivationCest
253253
{
@@ -288,19 +288,19 @@ TEST_TABLE_PREFIX=test_
288288
WORDPRESS_TABLE_PREFIX=wp_
289289

290290
# The URL and domain of the WordPress site used in end-to-end tests.
291-
WORDPRESS_URL=http://localhost:24356
292-
WORDPRESS_DOMAIN=localhost:24356
291+
WORDPRESS_URL=http://localhost:20511
292+
WORDPRESS_DOMAIN=localhost:20511
293293

294294
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
295295
WORDPRESS_ADMIN_USER=admin
296296
WORDPRESS_ADMIN_PASSWORD=password
297297

298298
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
299299
CHROMEDRIVER_HOST=localhost
300-
CHROMEDRIVER_PORT=54335
300+
CHROMEDRIVER_PORT=50604
301301

302302
# The port on which the PHP built-in server will serve the WordPress installation.
303-
BUILTIN_SERVER_PORT=24356
303+
BUILTIN_SERVER_PORT=20511
304304

305305
<<< /tests/.env <<<
306306

0 commit comments

Comments
 (0)