From 805f1ef0196c26fdb22eebe2e8a772cc36e86497 Mon Sep 17 00:00:00 2001 From: Michael Reichardt Date: Mon, 25 Mar 2024 22:23:31 +0100 Subject: [PATCH] Add e2e tests --- .../Step/RunWordPressInstallerStepRunner.php | 39 +++++++++++-------- tests/e2e/PhpBlueprintTest.php | 4 ++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php b/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php index b3b78a9a..2ab371ea 100644 --- a/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php +++ b/src/WordPress/Blueprints/Runner/Step/RunWordPressInstallerStepRunner.php @@ -2,6 +2,7 @@ namespace WordPress\Blueprints\Runner\Step; +use PHPUnit\Exception; use WordPress\Blueprints\Model\DataClass\RunWordPressInstallerStep; use WordPress\Blueprints\Progress\Tracker; @@ -11,22 +12,28 @@ class RunWordPressInstallerStepRunner extends BaseStepRunner { * @param \WordPress\Blueprints\Progress\Tracker $tracker */ function run( $input, $tracker ) { - $result = $this->getRuntime()->runShellCommand( - array( - 'php', - 'wp-cli.phar', - '--allow-root', - 'core', - 'install', - '--url=http://localhost:8081', - '--title=Playground Site', - '--admin_user=' . $input->options->adminUsername, - '--admin_password=' . $input->options->adminPassword, - '--admin_email=admin@wordpress.internal', - ), - $this->getRuntime()->getDocumentRoot() - ); - return trim( $result ); + var_dump( $input ); + try { + $result = $this->getRuntime()->runShellCommand( + array( + 'php', + 'wp-cli.phar', + '--allow-root', + 'core', + 'install', + '--url=http://localhost:8081', + '--title=Playground Site', + '--admin_user=' . $input->options->adminUsername, + '--admin_password=' . $input->options->adminPassword, + '--admin_email=admin@wordpress.internal', + ), + $this->getRuntime()->getDocumentRoot() + ); + return trim( $result ); + } catch ( Exception $exception ) { + var_dump( $exception ); + } + return null; } public function getDefaultCaption( $input ) { diff --git a/tests/e2e/PhpBlueprintTest.php b/tests/e2e/PhpBlueprintTest.php index 5de84bb6..7be07255 100644 --- a/tests/e2e/PhpBlueprintTest.php +++ b/tests/e2e/PhpBlueprintTest.php @@ -92,6 +92,10 @@ public function testRunningPhpBlueprintWithWordPressVersion() { 3 => new StepSuccess( $run_word_press_installer_step, 'Success: WordPress installed successfully.' ) ); +// - 'result' => 'Success: WordPress installed successfully.' +// + 'result' => '#!/usr/bin/env php\n +// + Success: WordPress installed successfully.' + //@TODO Assert WP files exist self::assertEquals( $expected, $results );