diff --git a/CHANGELOG.md b/CHANGELOG.md index b071e9b51..9ef816852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] Unreleased +### Changed + +- Update init template to scaffold dump file path and example tests correctly (thanks @tarecord). + ## [3.5.4] 2024-03-19; ### Fixed diff --git a/src/Project/PluginProject.php b/src/Project/PluginProject.php index ebe852e9d..289e223a8 100644 --- a/src/Project/PluginProject.php +++ b/src/Project/PluginProject.php @@ -2,12 +2,12 @@ namespace lucatume\WPBrowser\Project; +use Codeception\Codecept; use lucatume\WPBrowser\Exceptions\InvalidArgumentException; use lucatume\WPBrowser\Exceptions\RuntimeException; use lucatume\WPBrowser\Process\Loop; use lucatume\WPBrowser\Process\ProcessException; use lucatume\WPBrowser\Process\WorkerException; -use lucatume\WPBrowser\TestCase\WPTestCase; use lucatume\WPBrowser\Utils\Filesystem as FS; use lucatume\WPBrowser\Utils\Strings; use lucatume\WPBrowser\WordPress\CodeExecution\CodeExecutionFactory; @@ -128,9 +128,11 @@ public function activate(string $wpRootDir, int $serverLocalhostPort): bool $message = $activationResult->getMessage(); $this->sayWarning('Could not activate plugin: ' . $message); $this->say($activationResult->getFile() . ":" . $activationResult->getLine()); + // @phpstan-ignore-next-line + $dumpPath = Codecept::VERSION >= 5 ? 'tests/Support/Data/dump.sql' : 'tests/_data/dump.sql'; $this->say('This might happen because the plugin has unmet dependencies; wp-browser configuration ' . 'will continue, but you will need to manually activate the plugin and update the dump in ' . - 'tests/Support/Data/dump.sql.'); + $dumpPath); return false; } @@ -141,13 +143,15 @@ public function activate(string $wpRootDir, int $serverLocalhostPort): bool protected function scaffoldEndToEndActivationCest(): void { + // @phpstan-ignore-next-line + $testerTrait = Codecept::VERSION >= 5 ? 'Tests\Support\EndToEndTester' : 'EndToEndTester'; $cestCode = Strings::renderString( <<= 5 ? 'Tests\Support\EndToEndTester' : 'EndToEndTester'; $cestCode = <<< EOT toSwitchTheme($this->basename, false); $activationResult = Loop::executeClosure($switchTheme)->getReturnValue(); if ($activationResult instanceof Throwable) { + // @phpstan-ignore-next-line + $dumpPath = Codecept::VERSION >= 5 ? 'tests/Support/Data/dump.sql' : 'tests/_data/dump.sql'; $message = $activationResult->getMessage(); $this->sayWarning('Could not activate theme: ' . $message); $this->say('This might happen because the theme has unmet dependencies; wp-browser configuration ' . 'will continue, but you will need to manually activate the theme and update the dump in ' . - 'tests/Support/Data/dump.sql.'); + $dumpPath); return false; } @@ -129,13 +132,15 @@ public function activate(string $wpRootDir, int $serverLocalhostPort): bool protected function scaffoldEndToEndActivationCest(): void { + // @phpstan-ignore-next-line + $testerTrait = Codecept::VERSION >= 5 ? 'Tests\Support\EndToEndTester' : 'EndToEndTester'; $cestCode = Strings::renderString( <<= 5 ? 'tests/Support/Data/dump.sql' : 'tests/_data/dump.sql'; $suiteConfig = <<