From 428d6eab88fb700650e917d31dc3a55592880914 Mon Sep 17 00:00:00 2001 From: Michael Reichardt Date: Mon, 18 Mar 2024 15:40:48 +0100 Subject: [PATCH 1/2] Add e2e tests - fix reference in blueprint_compiling.php and json_string_compiling.php - downgrade code to PHP == 7.0 --- examples/blueprint_compiling.php | 2 +- examples/json_string_compiling.php | 2 +- src/WordPress/Blueprints/BlueprintParser.php | 1 + tests/E2E/JsonBlueprintTest.php | 97 +++++++++++++ tests/E2E/PhpBlueprintTest.php | 135 +++++++++++++++++++ 5 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 tests/E2E/JsonBlueprintTest.php create mode 100644 tests/E2E/PhpBlueprintTest.php diff --git a/examples/blueprint_compiling.php b/examples/blueprint_compiling.php index 98686598..7db5bcbc 100644 --- a/examples/blueprint_compiling.php +++ b/examples/blueprint_compiling.php @@ -14,7 +14,7 @@ if ( getenv( 'USE_PHAR' ) ) { require __DIR__ . '/dist/blueprints.phar'; } else { - require 'vendor/autoload.php'; + require '../vendor/autoload.php'; } $blueprint = BlueprintBuilder::create() diff --git a/examples/json_string_compiling.php b/examples/json_string_compiling.php index 012426a0..609532e1 100644 --- a/examples/json_string_compiling.php +++ b/examples/json_string_compiling.php @@ -13,7 +13,7 @@ if ( getenv( 'USE_PHAR' ) ) { require __DIR__ . '/dist/blueprints.phar'; } else { - require 'vendor/autoload.php'; + require '../vendor/autoload.php'; } $blueprint = '{"WordPressVersion":"https://wordpress.org/latest.zip","steps":[{"step":"mkdir","path":"dir"},{"step": "rm","path": "dir"}]}'; diff --git a/src/WordPress/Blueprints/BlueprintParser.php b/src/WordPress/Blueprints/BlueprintParser.php index 28374406..10af023d 100644 --- a/src/WordPress/Blueprints/BlueprintParser.php +++ b/src/WordPress/Blueprints/BlueprintParser.php @@ -72,6 +72,7 @@ public function fromObject( $data ) { */ public function fromBlueprint( $blueprint ) { $result = $this->validator->validate( $blueprint ); + // @TODO make the error understandable if ( ! $result->isValid() ) { print_r( ( new ErrorFormatter() )->format( $result->error() ) ); die(); diff --git a/tests/E2E/JsonBlueprintTest.php b/tests/E2E/JsonBlueprintTest.php new file mode 100644 index 00000000..9d9f5c0f --- /dev/null +++ b/tests/E2E/JsonBlueprintTest.php @@ -0,0 +1,97 @@ +document_root = Path::makeAbsolute( 'test', sys_get_temp_dir() ); + + $this->subscriber = new class() implements EventSubscriberInterface { + public static function getSubscribedEvents() { + return array( + ProgressEvent::class => 'onProgress', + DoneEvent::class => 'onDone', + ); + } + + protected $progress_bar; + + public function __construct() { + ProgressBar::setFormatDefinition( 'custom', ' [%bar%] %current%/%max% -- %message%' ); + + $this->progress_bar = ( new SymfonyStyle( + new StringInput( '' ), + new ConsoleOutput() + ) )->createProgressBar( 100 ); + $this->progress_bar->setFormat( 'custom' ); + $this->progress_bar->setMessage( 'Start' ); + $this->progress_bar->start(); + } + + public function onProgress( ProgressEvent $event ) { + $this->progress_bar->setMessage( $event->caption ); + $this->progress_bar->setProgress( (int) $event->progress ); + } + + public function onDone( DoneEvent $event ) { + $this->progress_bar->finish(); + } + }; + } + + /** + * @after + */ + public function after() { + ( new Filesystem() )->remove( $this->document_root ); + } + public function testRunningJsonBlueprintWithWordPressVersion() { + $blueprint = '{"WordPressVersion":"https://wordpress.org/latest.zip"}'; + + $results = run_blueprint( + $blueprint, + array( + 'environment' => ContainerBuilder::ENVIRONMENT_NATIVE, + 'documentRoot' => $this->document_root . '/new-wp', + 'progressSubscriber' => $this->subscriber, + ) + ); + + $expected = array( +// 0 => new StepSuccess(), +// 1 => new StepSuccess(), +// 2 => new StepSuccess(), +// 3 => new StepSuccess(), + ); + + // @TODO fix expected + $this->assertEquals( array(), $results ); + } +} diff --git a/tests/E2E/PhpBlueprintTest.php b/tests/E2E/PhpBlueprintTest.php new file mode 100644 index 00000000..9f35abb4 --- /dev/null +++ b/tests/E2E/PhpBlueprintTest.php @@ -0,0 +1,135 @@ +document_root = Path::makeAbsolute( 'test', sys_get_temp_dir() ); + + $this->subscriber = new class() implements EventSubscriberInterface { + public static function getSubscribedEvents() { + return array( + ProgressEvent::class => 'onProgress', + DoneEvent::class => 'onDone', + ); + } + + protected $progress_bar; + + public function __construct() { + ProgressBar::setFormatDefinition( 'custom', ' [%bar%] %current%/%max% -- %message%' ); + + $this->progress_bar = ( new SymfonyStyle( + new StringInput( '' ), + new ConsoleOutput() + ) )->createProgressBar( 100 ); + $this->progress_bar->setFormat( 'custom' ); + $this->progress_bar->setMessage( 'Start' ); + $this->progress_bar->start(); + } + + public function onProgress( ProgressEvent $event ) { + $this->progress_bar->setMessage( $event->caption ); + $this->progress_bar->setProgress( (int) $event->progress ); + } + + public function onDone( DoneEvent $event ) { + $this->progress_bar->finish(); + } + }; + } + + /** + * @after + */ + public function after() { + ( new Filesystem() )->remove( $this->document_root ); + } + + // public function testRunningPhpBlueprintWithWordPressVersion() { + // $blueprint = BlueprintBuilder::create() + // ->withWordPressVersion( 'https://wordpress.org/latest.zip' ) + // ->toBlueprint(); + // + // $results = run_blueprint( + // $blueprint, + // array( + // 'environment' => ContainerBuilder::ENVIRONMENT_NATIVE, + // 'documentRoot' => $this->document_root . '/new-wp', + // 'progressSubscriber' => $this->subscriber, + // ) + // ); + // + // $expected = array( + // 0 => new StepSuccess(), + // 1 => new StepSuccess(), + // 2 => new StepSuccess(), + // 3 => new StepSuccess(), + // 4 => new StepSuccess(), + // ); + // + // @TODO fix expected + // $this->assertEquals( $expected, $results ); + // } + + public function testRunningPhpBlueprintWithSteps() { + $blueprint = BlueprintBuilder::create() + ->addStep( ( new MkdirStep() )->setPath( 'dir1' ) ) + ->addStep( ( new RmStep() )->setPath( 'dir1' ) ) + ->addStep( ( new MkdirStep() )->setPath( 'dir2' ) ) + ->toBlueprint(); + + // the above does not pass validation + + $results = run_blueprint( + $blueprint, + array( + 'environment' => ContainerBuilder::ENVIRONMENT_NATIVE, + 'documentRoot' => $this->document_root . '/new-wp', + 'progressSubscriber' => $this->subscriber, + ) + ); + + $expected = array(); + +// array( +// 0 => new StepSuccess( new MkdirStep(), true ), +// 1 => new StepSuccess( new RmStep(), true ), +// 2 => new StepSuccess( new MkdirStep(), true ), +// ); + $this->expectNotToPerformAssertions(); + +// $this->assertEquals( $expected, $results ); + } +} From 92d2559029eaf44cfe62543730b69f61106a27c3 Mon Sep 17 00:00:00 2001 From: Michael Reichardt Date: Tue, 19 Mar 2024 18:25:46 +0100 Subject: [PATCH 2/2] Test --- README.md | 2 +- .../Model/DataClass/ActivatePluginStep.php | 29 +++------ .../Model/DataClass/ActivateThemeStep.php | 29 +++------ .../Blueprints/Model/DataClass/Blueprint.php | 65 +++++++------------ .../Model/DataClass/BlueprintOnBoot.php | 17 ++--- .../Model/DataClass/CorePluginResource.php | 18 ++--- .../Model/DataClass/CoreThemeResource.php | 18 ++--- .../Blueprints/Model/DataClass/CpStep.php | 36 ++++------ .../Model/DataClass/DefineSiteUrlStep.php | 29 +++------ .../DataClass/DefineWpConfigConstsStep.php | 29 +++------ .../Model/DataClass/DownloadWordPressStep.php | 25 +++---- .../Model/DataClass/EnableMultisiteStep.php | 22 +++---- .../Model/DataClass/EvalPHPCallbackStep.php | 27 +++----- .../Blueprints/Model/DataClass/FileInfo.php | 28 +++----- .../Model/DataClass/FileInfoData.php | 34 ++++------ .../Model/DataClass/FileInfoDataBuffer.php | 10 ++- .../Model/DataClass/FilesystemResource.php | 18 ++--- .../Model/DataClass/ImportFileStep.php | 25 +++---- .../Model/DataClass/InlineResource.php | 18 ++--- .../Model/DataClass/InstallPluginStep.php | 37 ++++------- .../InstallSqliteIntegrationStep.php | 25 +++---- .../Model/DataClass/InstallThemeStep.php | 33 ++++------ .../Blueprints/Model/DataClass/MkdirStep.php | 29 +++------ .../Blueprints/Model/DataClass/ModelInfo.php | 22 ++++--- .../Blueprints/Model/DataClass/MvStep.php | 36 ++++------ .../Blueprints/Model/DataClass/Progress.php | 16 ++--- .../DataClass/ResourceDefinitionInterface.php | 4 +- .../Blueprints/Model/DataClass/RmStep.php | 29 +++------ .../Blueprints/Model/DataClass/RunPHPStep.php | 30 +++------ .../Blueprints/Model/DataClass/RunSQLStep.php | 26 +++----- .../DataClass/RunWordPressInstallerStep.php | 28 +++----- .../Model/DataClass/SetSiteOptionsStep.php | 30 +++------ .../DataClass/StepDefinitionInterface.php | 4 +- .../Blueprints/Model/DataClass/UnzipStep.php | 32 ++++----- .../Model/DataClass/UrlResource.php | 25 +++---- .../Blueprints/Model/DataClass/WPCLIStep.php | 30 +++------ .../WordPressInstallationOptions.php | 16 ++--- .../Model/DataClass/WriteFileStep.php | 33 ++++------ src/WordPress/Blueprints/functions.php | 2 +- tests/E2E/JsonBlueprintTest.php | 23 +++++++ tests/E2E/PhpBlueprintTest.php | 7 +- 41 files changed, 373 insertions(+), 623 deletions(-) diff --git a/README.md b/README.md index c2b6b9a3..a0402367 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ vendor/bin/phpunit --testdox php examples/blueprint_compiling.php ``` -#### using a string containg a Blueprint (in JSON): +#### using a string containing a Blueprint (in JSON): ```shell php examples/json_string_compiling.php diff --git a/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php b/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php index c36a1542..4538d564 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class ActivatePluginStep implements StepDefinitionInterface { - +class ActivatePluginStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'activatePlugin'; /** @var Progress */ @@ -17,43 +17,34 @@ class ActivatePluginStep implements StepDefinitionInterface { /** * Plugin slug, like 'gutenberg' or 'hello-dolly'. - * * @var string */ public $slug; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $slug - */ - public function setSlug( $slug ) { + public function setSlug(string $slug) + { $this->slug = $slug; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php b/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php index 1d019cca..8d93b861 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class ActivateThemeStep implements StepDefinitionInterface { - +class ActivateThemeStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'activateTheme'; /** @var Progress */ @@ -17,43 +17,34 @@ class ActivateThemeStep implements StepDefinitionInterface { /** * Theme slug, like 'twentytwentythree'. - * * @var string */ public $slug; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $slug - */ - public function setSlug( $slug ) { + public function setSlug(string $slug) + { $this->slug = $slug; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/Blueprint.php b/src/WordPress/Blueprints/Model/DataClass/Blueprint.php index 99d6e4b1..6257788e 100644 --- a/src/WordPress/Blueprints/Model/DataClass/Blueprint.php +++ b/src/WordPress/Blueprints/Model/DataClass/Blueprint.php @@ -2,24 +2,22 @@ namespace WordPress\Blueprints\Model\DataClass; -class Blueprint { +class Blueprint +{ /** * Optional description. It doesn't do anything but is exposed as a courtesy to developers who may want to document which blueprint file does what. - * * @var string */ public $description = ''; /** * Version of WordPress to use. Also accepts URL to a WordPress zip file. - * * @var string */ public $WordPressVersion; /** * Slot for runtime–specific options, schema must be provided by the runtime. - * * @var \ArrayObject */ public $runtime; @@ -29,100 +27,81 @@ class Blueprint { /** * PHP Constants to define on every request - * * @var \ArrayObject */ - public $constants = array(); + public $constants = []; /** * WordPress plugins to install and activate - * * @var string[]|ResourceDefinitionInterface[] */ - public $plugins = array(); + public $plugins = []; /** * WordPress site options to define - * * @var \ArrayObject */ - public $siteOptions = array(); + public $siteOptions = []; /** * The steps to run after every other operation in this Blueprint was executed. - * * @var StepDefinitionInterface[] */ - public $steps = array(); + public $steps = []; - /** - * @param string $description - */ - public function setDescription( $description ) { + public function setDescription(string $description) + { $this->description = $description; - return $this; } - /** - * @param string $WordPressVersion - */ - public function setWordPressVersion( $WordPressVersion ) { + public function setWordPressVersion(string $WordPressVersion) + { $this->WordPressVersion = $WordPressVersion; - return $this; } - public function setRuntime( $runtime ) { + public function setRuntime(iterable $runtime) + { $this->runtime = $runtime; - return $this; } - /** - * @param \WordPress\Blueprints\Model\DataClass\BlueprintOnBoot $onBoot - */ - public function setOnBoot( $onBoot ) { + public function setOnBoot(BlueprintOnBoot $onBoot) + { $this->onBoot = $onBoot; - return $this; } - public function setConstants( $constants ) { + public function setConstants(iterable $constants) + { $this->constants = $constants; - return $this; } - /** - * @param mixed[] $plugins - */ - public function setPlugins( $plugins ) { + public function setPlugins(array $plugins) + { $this->plugins = $plugins; - return $this; } - public function setSiteOptions( $siteOptions ) { + public function setSiteOptions(iterable $siteOptions) + { $this->siteOptions = $siteOptions; - return $this; } - /** - * @param mixed[] $steps - */ - public function setSteps( $steps ) { + public function setSteps(array $steps) + { $this->steps = $steps; - return $this; } } diff --git a/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php b/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php index c91c17f6..a091a052 100644 --- a/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php +++ b/src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php @@ -2,11 +2,10 @@ namespace WordPress\Blueprints\Model\DataClass; -class BlueprintOnBoot { - +class BlueprintOnBoot +{ /** * The URL to navigate to after the blueprint has been run. - * * @var string */ public $openUrl; @@ -15,19 +14,15 @@ class BlueprintOnBoot { public $login; - /** - * @param string $openUrl - */ - public function setOpenUrl( $openUrl ) { + public function setOpenUrl(string $openUrl) + { $this->openUrl = $openUrl; return $this; } - /** - * @param bool $login - */ - public function setLogin( $login ) { + public function setLogin(bool $login) + { $this->login = $login; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php b/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php index 0c18d971..086d45c1 100644 --- a/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php @@ -2,38 +2,32 @@ namespace WordPress\Blueprints\Model\DataClass; -class CorePluginResource implements ResourceDefinitionInterface { - +class CorePluginResource implements ResourceDefinitionInterface +{ const DISCRIMINATOR = 'wordpress.org/plugins'; /** * Identifies the file resource as a WordPress Core plugin - * * @var string */ public $resource = 'wordpress.org/plugins'; /** * The slug of the WordPress Core plugin - * * @var string */ public $slug; - /** - * @param string $resource - */ - public function setResource( $resource ) { + public function setResource(string $resource) + { $this->resource = $resource; return $this; } - /** - * @param string $slug - */ - public function setSlug( $slug ) { + public function setSlug(string $slug) + { $this->slug = $slug; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php b/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php index 20785f19..e7015a0a 100644 --- a/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/CoreThemeResource.php @@ -2,38 +2,32 @@ namespace WordPress\Blueprints\Model\DataClass; -class CoreThemeResource implements ResourceDefinitionInterface { - +class CoreThemeResource implements ResourceDefinitionInterface +{ const DISCRIMINATOR = 'wordpress.org/themes'; /** * Identifies the file resource as a WordPress Core theme - * * @var string */ public $resource = 'wordpress.org/themes'; /** * The slug of the WordPress Core theme - * * @var string */ public $slug; - /** - * @param string $resource - */ - public function setResource( $resource ) { + public function setResource(string $resource) + { $this->resource = $resource; return $this; } - /** - * @param string $slug - */ - public function setSlug( $slug ) { + public function setSlug(string $slug) + { $this->slug = $slug; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/CpStep.php b/src/WordPress/Blueprints/Model/DataClass/CpStep.php index 5b4c16c7..08d81a7d 100644 --- a/src/WordPress/Blueprints/Model/DataClass/CpStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/CpStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class CpStep implements StepDefinitionInterface { - +class CpStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'cp'; /** @var Progress */ @@ -17,59 +17,47 @@ class CpStep implements StepDefinitionInterface { /** * Source path - * * @var string */ public $fromPath; /** * Target path - * * @var string */ public $toPath; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $fromPath - */ - public function setFromPath( $fromPath ) { + public function setFromPath(string $fromPath) + { $this->fromPath = $fromPath; return $this; } - /** - * @param string $toPath - */ - public function setToPath( $toPath ) { + public function setToPath(string $toPath) + { $this->toPath = $toPath; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php b/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php index 07433cee..5ade7609 100644 --- a/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/DefineSiteUrlStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class DefineSiteUrlStep implements StepDefinitionInterface { - +class DefineSiteUrlStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'defineSiteUrl'; /** @var Progress */ @@ -17,43 +17,34 @@ class DefineSiteUrlStep implements StepDefinitionInterface { /** * The URL - * * @var string */ public $siteUrl; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $siteUrl - */ - public function setSiteUrl( $siteUrl ) { + public function setSiteUrl(string $siteUrl) + { $this->siteUrl = $siteUrl; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php b/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php index ae227048..d75f533b 100644 --- a/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/DefineWpConfigConstsStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class DefineWpConfigConstsStep implements StepDefinitionInterface { - +class DefineWpConfigConstsStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'defineWpConfigConsts'; /** @var Progress */ @@ -17,43 +17,34 @@ class DefineWpConfigConstsStep implements StepDefinitionInterface { /** * The constants to define - * * @var \ArrayObject */ public $consts; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param iterable $consts - */ - public function setConsts( $consts ) { + public function setConsts(iterable $consts) + { $this->consts = $consts; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php b/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php index d60a6eba..432fb9c3 100644 --- a/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/DownloadWordPressStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class DownloadWordPressStep implements StepDefinitionInterface { - +class DownloadWordPressStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'downloadWordPress'; /** @var Progress */ @@ -19,34 +19,29 @@ class DownloadWordPressStep implements StepDefinitionInterface { public $wordPressZip; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - public function setWordPressZip( $wordPressZip ) { + public function setWordPressZip($wordPressZip) + { $this->wordPressZip = $wordPressZip; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php b/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php index 8c381b9c..e47d2be2 100644 --- a/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/EnableMultisiteStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class EnableMultisiteStep implements StepDefinitionInterface { - +class EnableMultisiteStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'enableMultisite'; /** @var Progress */ @@ -16,28 +16,22 @@ class EnableMultisiteStep implements StepDefinitionInterface { public $step = 'enableMultisite'; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php b/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php index 1e5eb6a7..0bf34c2d 100644 --- a/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/EvalPHPCallbackStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class EvalPHPCallbackStep implements StepDefinitionInterface { - +class EvalPHPCallbackStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'evalPHPCallback'; /** @var Progress */ @@ -14,47 +14,40 @@ class EvalPHPCallbackStep implements StepDefinitionInterface { /** * The step identifier. - * * @var string */ public $step = 'evalPHPCallback'; /** * The PHP function. - * * @var mixed */ public $callback; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - public function setCallback( $callback ) { + public function setCallback($callback) + { $this->callback = $callback; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/FileInfo.php b/src/WordPress/Blueprints/Model/DataClass/FileInfo.php index fc1ab214..0ed00e2a 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FileInfo.php +++ b/src/WordPress/Blueprints/Model/DataClass/FileInfo.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class FileInfo { - +class FileInfo +{ /** @var string */ public $key; @@ -17,37 +17,29 @@ class FileInfo { public $data; - /** - * @param string $key - */ - public function setKey( $key ) { + public function setKey(string $key) + { $this->key = $key; return $this; } - /** - * @param string $name - */ - public function setName( $name ) { + public function setName(string $name) + { $this->name = $name; return $this; } - /** - * @param string $type - */ - public function setType( $type ) { + public function setType(string $type) + { $this->type = $type; return $this; } - /** - * @param \WordPress\Blueprints\Model\DataClass\FileInfoData $data - */ - public function setData( $data ) { + public function setData(FileInfoData $data) + { $this->data = $data; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php b/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php index 72ef3ce2..9638f0e9 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php +++ b/src/WordPress/Blueprints/Model/DataClass/FileInfoData.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class FileInfoData { - +class FileInfoData +{ /** @var float */ public $BYTES_PER_ELEMENT; @@ -20,46 +20,36 @@ class FileInfoData { public $length; - /** - * @param float $BYTES_PER_ELEMENT - */ - public function setBYTES_PER_ELEMENT( $BYTES_PER_ELEMENT ) { + public function setBYTES_PER_ELEMENT(float $BYTES_PER_ELEMENT) + { $this->BYTES_PER_ELEMENT = $BYTES_PER_ELEMENT; return $this; } - /** - * @param \WordPress\Blueprints\Model\DataClass\FileInfoDataBuffer $buffer - */ - public function setBuffer( $buffer ) { + public function setBuffer(FileInfoDataBuffer $buffer) + { $this->buffer = $buffer; return $this; } - /** - * @param float $byteLength - */ - public function setByteLength( $byteLength ) { + public function setByteLength(float $byteLength) + { $this->byteLength = $byteLength; return $this; } - /** - * @param float $byteOffset - */ - public function setByteOffset( $byteOffset ) { + public function setByteOffset(float $byteOffset) + { $this->byteOffset = $byteOffset; return $this; } - /** - * @param float $length - */ - public function setLength( $length ) { + public function setLength(float $length) + { $this->length = $length; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php b/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php index a1d03063..9bb4dfc8 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php +++ b/src/WordPress/Blueprints/Model/DataClass/FileInfoDataBuffer.php @@ -2,16 +2,14 @@ namespace WordPress\Blueprints\Model\DataClass; -class FileInfoDataBuffer { - +class FileInfoDataBuffer +{ /** @var float */ public $byteLength; - /** - * @param float $byteLength - */ - public function setByteLength( $byteLength ) { + public function setByteLength(float $byteLength) + { $this->byteLength = $byteLength; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php b/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php index 9637f215..2c72c182 100644 --- a/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/FilesystemResource.php @@ -2,38 +2,32 @@ namespace WordPress\Blueprints\Model\DataClass; -class FilesystemResource implements ResourceDefinitionInterface { - +class FilesystemResource implements ResourceDefinitionInterface +{ const DISCRIMINATOR = 'filesystem'; /** * Identifies the file resource as Virtual File System (VFS) - * * @var string */ public $resource = 'filesystem'; /** * The path to the file in the VFS - * * @var string */ public $path; - /** - * @param string $resource - */ - public function setResource( $resource ) { + public function setResource(string $resource) + { $this->resource = $resource; return $this; } - /** - * @param string $path - */ - public function setPath( $path ) { + public function setPath(string $path) + { $this->path = $path; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php b/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php index caa11d88..c4dd3310 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/ImportFileStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class ImportFileStep implements StepDefinitionInterface { - +class ImportFileStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'importFile'; /** @var Progress */ @@ -19,34 +19,29 @@ class ImportFileStep implements StepDefinitionInterface { public $file; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - public function setFile( $file ) { + public function setFile($file) + { $this->file = $file; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/InlineResource.php b/src/WordPress/Blueprints/Model/DataClass/InlineResource.php index 8e2ec36e..fa3bde2f 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InlineResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/InlineResource.php @@ -2,38 +2,32 @@ namespace WordPress\Blueprints\Model\DataClass; -class InlineResource implements ResourceDefinitionInterface { - +class InlineResource implements ResourceDefinitionInterface +{ const DISCRIMINATOR = 'inline'; /** * Identifies the file resource as an inline string - * * @var string */ public $resource = 'inline'; /** * The contents of the file - * * @var string */ public $contents; - /** - * @param string $resource - */ - public function setResource( $resource ) { + public function setResource(string $resource) + { $this->resource = $resource; return $this; } - /** - * @param string $contents - */ - public function setContents( $contents ) { + public function setContents(string $contents) + { $this->contents = $contents; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php b/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php index 1da3cb0c..d4ea14ca 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/InstallPluginStep.php @@ -2,7 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class InstallPluginStep implements StepDefinitionInterface { +class InstallPluginStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'installPlugin'; /** @var Progress */ @@ -13,7 +14,6 @@ class InstallPluginStep implements StepDefinitionInterface { /** * The step identifier. - * * @var string */ public $step = 'installPlugin'; @@ -23,55 +23,42 @@ class InstallPluginStep implements StepDefinitionInterface { /** * Whether to activate the plugin after installing it. - * * @var bool */ public $activate = true; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; - return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; - return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; - return $this; } - public function setPluginZipFile( $pluginZipFile ) { + public function setPluginZipFile($pluginZipFile) + { $this->pluginZipFile = $pluginZipFile; - return $this; } - /** - * @param bool $activate - */ - public function setActivate( $activate ) { + public function setActivate(bool $activate) + { $this->activate = $activate; - return $this; } } diff --git a/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php b/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php index d13f5bb2..a96aef15 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/InstallSqliteIntegrationStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class InstallSqliteIntegrationStep implements StepDefinitionInterface { - +class InstallSqliteIntegrationStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'installSqliteIntegration'; /** @var Progress */ @@ -19,34 +19,29 @@ class InstallSqliteIntegrationStep implements StepDefinitionInterface { public $sqlitePluginZip; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - public function setSqlitePluginZip( $sqlitePluginZip ) { + public function setSqlitePluginZip($sqlitePluginZip) + { $this->sqlitePluginZip = $sqlitePluginZip; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php b/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php index 05bf1a69..a862fad6 100644 --- a/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/InstallThemeStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class InstallThemeStep implements StepDefinitionInterface { - +class InstallThemeStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'installTheme'; /** @var Progress */ @@ -14,7 +14,6 @@ class InstallThemeStep implements StepDefinitionInterface { /** * The step identifier. - * * @var string */ public $step = 'installTheme'; @@ -24,49 +23,41 @@ class InstallThemeStep implements StepDefinitionInterface { /** * Whether to activate the theme after installing it. - * * @var bool */ public $activate = true; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - public function setThemeZipFile( $themeZipFile ) { + public function setThemeZipFile($themeZipFile) + { $this->themeZipFile = $themeZipFile; return $this; } - /** - * @param bool $activate - */ - public function setActivate( $activate ) { + public function setActivate(bool $activate) + { $this->activate = $activate; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php b/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php index efcb6e51..911ee9da 100644 --- a/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/MkdirStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class MkdirStep implements StepDefinitionInterface { - +class MkdirStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'mkdir'; /** @var Progress */ @@ -17,43 +17,34 @@ class MkdirStep implements StepDefinitionInterface { /** * The path of the directory you want to create - * * @var string */ public $path; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $path - */ - public function setPath( $path ) { + public function setPath(string $path) + { $this->path = $path; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/ModelInfo.php b/src/WordPress/Blueprints/Model/DataClass/ModelInfo.php index 322a60a3..ae54db72 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ModelInfo.php +++ b/src/WordPress/Blueprints/Model/DataClass/ModelInfo.php @@ -2,21 +2,23 @@ namespace WordPress\Blueprints\Model\DataClass; -class ModelInfo { - - public static function getResourceDefinitionInterfaceImplementations(): array { - return array( +class ModelInfo +{ + public static function getResourceDefinitionInterfaceImplementations(): array + { + return [ FilesystemResource::class, InlineResource::class, CoreThemeResource::class, CorePluginResource::class, - UrlResource::class, - ); + UrlResource::class + ]; } - public static function getStepDefinitionInterfaceImplementations(): array { - return array( + public static function getStepDefinitionInterfaceImplementations(): array + { + return [ ActivatePluginStep::class, ActivateThemeStep::class, CpStep::class, @@ -38,7 +40,7 @@ public static function getStepDefinitionInterfaceImplementations(): array { DownloadWordPressStep::class, InstallSqliteIntegrationStep::class, WriteFileStep::class, - WPCLIStep::class, - ); + WPCLIStep::class + ]; } } diff --git a/src/WordPress/Blueprints/Model/DataClass/MvStep.php b/src/WordPress/Blueprints/Model/DataClass/MvStep.php index c596ab1a..736d18aa 100644 --- a/src/WordPress/Blueprints/Model/DataClass/MvStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/MvStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class MvStep implements StepDefinitionInterface { - +class MvStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'mv'; /** @var Progress */ @@ -17,59 +17,47 @@ class MvStep implements StepDefinitionInterface { /** * Source path - * * @var string */ public $fromPath; /** * Target path - * * @var string */ public $toPath; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $fromPath - */ - public function setFromPath( $fromPath ) { + public function setFromPath(string $fromPath) + { $this->fromPath = $fromPath; return $this; } - /** - * @param string $toPath - */ - public function setToPath( $toPath ) { + public function setToPath(string $toPath) + { $this->toPath = $toPath; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/Progress.php b/src/WordPress/Blueprints/Model/DataClass/Progress.php index 06261350..4ae54958 100644 --- a/src/WordPress/Blueprints/Model/DataClass/Progress.php +++ b/src/WordPress/Blueprints/Model/DataClass/Progress.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class Progress { - +class Progress +{ /** @var float */ public $weight; @@ -11,19 +11,15 @@ class Progress { public $caption; - /** - * @param float $weight - */ - public function setWeight( $weight ) { + public function setWeight(float $weight) + { $this->weight = $weight; return $this; } - /** - * @param string $caption - */ - public function setCaption( $caption ) { + public function setCaption(string $caption) + { $this->caption = $caption; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/ResourceDefinitionInterface.php b/src/WordPress/Blueprints/Model/DataClass/ResourceDefinitionInterface.php index b156c3fc..8bee1256 100644 --- a/src/WordPress/Blueprints/Model/DataClass/ResourceDefinitionInterface.php +++ b/src/WordPress/Blueprints/Model/DataClass/ResourceDefinitionInterface.php @@ -2,6 +2,6 @@ namespace WordPress\Blueprints\Model\DataClass; -interface ResourceDefinitionInterface { - +interface ResourceDefinitionInterface +{ } diff --git a/src/WordPress/Blueprints/Model/DataClass/RmStep.php b/src/WordPress/Blueprints/Model/DataClass/RmStep.php index 831afae6..c4a791ed 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RmStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RmStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class RmStep implements StepDefinitionInterface { - +class RmStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'rm'; /** @var Progress */ @@ -17,43 +17,34 @@ class RmStep implements StepDefinitionInterface { /** * The path to remove - * * @var string */ public $path; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $path - */ - public function setPath( $path ) { + public function setPath(string $path) + { $this->path = $path; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php b/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php index 63e5f9e0..ff2fb327 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RunPHPStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class RunPHPStep implements StepDefinitionInterface { - +class RunPHPStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'runPHP'; /** @var Progress */ @@ -14,50 +14,40 @@ class RunPHPStep implements StepDefinitionInterface { /** * The step identifier. - * * @var string */ public $step = 'runPHP'; /** * The PHP code to run. - * * @var string */ public $code; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $code - */ - public function setCode( $code ) { + public function setCode(string $code) + { $this->code = $code; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php b/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php index 8872ba3f..a63ad67e 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RunSQLStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class RunSQLStep implements StepDefinitionInterface { - +class RunSQLStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'runSql'; /** @var Progress */ @@ -14,7 +14,6 @@ class RunSQLStep implements StepDefinitionInterface { /** * The step identifier. - * * @var string */ public $step = 'runSql'; @@ -23,34 +22,29 @@ class RunSQLStep implements StepDefinitionInterface { public $sql; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - public function setSql( $sql ) { + public function setSql($sql) + { $this->sql = $sql; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php b/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php index 15744739..de109909 100644 --- a/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/RunWordPressInstallerStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class RunWordPressInstallerStep implements StepDefinitionInterface { - +class RunWordPressInstallerStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'runWpInstallationWizard'; /** @var Progress */ @@ -19,37 +19,29 @@ class RunWordPressInstallerStep implements StepDefinitionInterface { public $options; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param \WordPress\Blueprints\Model\DataClass\WordPressInstallationOptions $options - */ - public function setOptions( $options ) { + public function setOptions(WordPressInstallationOptions $options) + { $this->options = $options; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php b/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php index 4ee1bd19..d9f1dd36 100644 --- a/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/SetSiteOptionsStep.php @@ -2,7 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class SetSiteOptionsStep implements StepDefinitionInterface { +class SetSiteOptionsStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'setSiteOptions'; /** @var Progress */ @@ -13,52 +14,41 @@ class SetSiteOptionsStep implements StepDefinitionInterface { /** * The name of the step. Must be "setSiteOptions". - * * @var string */ public $step = 'setSiteOptions'; /** * The options to set on the site. - * * @var \ArrayObject */ public $options; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; - return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; - return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; - return $this; } - public function setOptions( $options ) { + public function setOptions(iterable $options) + { $this->options = $options; - return $this; } } diff --git a/src/WordPress/Blueprints/Model/DataClass/StepDefinitionInterface.php b/src/WordPress/Blueprints/Model/DataClass/StepDefinitionInterface.php index 451abfd2..84a42524 100644 --- a/src/WordPress/Blueprints/Model/DataClass/StepDefinitionInterface.php +++ b/src/WordPress/Blueprints/Model/DataClass/StepDefinitionInterface.php @@ -2,6 +2,6 @@ namespace WordPress\Blueprints\Model\DataClass; -interface StepDefinitionInterface { - +interface StepDefinitionInterface +{ } diff --git a/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php b/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php index 06ab8124..f107951d 100644 --- a/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/UnzipStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class UnzipStep implements StepDefinitionInterface { - +class UnzipStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'unzip'; /** @var Progress */ @@ -20,49 +20,41 @@ class UnzipStep implements StepDefinitionInterface { /** * The path to extract the zip file to - * * @var string */ public $extractToPath; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - public function setZipFile( $zipFile ) { + public function setZipFile($zipFile) + { $this->zipFile = $zipFile; return $this; } - /** - * @param string $extractToPath - */ - public function setExtractToPath( $extractToPath ) { + public function setExtractToPath(string $extractToPath) + { $this->extractToPath = $extractToPath; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/UrlResource.php b/src/WordPress/Blueprints/Model/DataClass/UrlResource.php index fa3b2d18..cd03093a 100644 --- a/src/WordPress/Blueprints/Model/DataClass/UrlResource.php +++ b/src/WordPress/Blueprints/Model/DataClass/UrlResource.php @@ -2,54 +2,45 @@ namespace WordPress\Blueprints\Model\DataClass; -class UrlResource implements ResourceDefinitionInterface { - +class UrlResource implements ResourceDefinitionInterface +{ const DISCRIMINATOR = 'url'; /** * Identifies the file resource as a URL - * * @var string */ public $resource = 'url'; /** * The URL of the file - * * @var string */ public $url; /** * Optional caption for displaying a progress message - * * @var string */ public $caption; - /** - * @param string $resource - */ - public function setResource( $resource ) { + public function setResource(string $resource) + { $this->resource = $resource; return $this; } - /** - * @param string $url - */ - public function setUrl( $url ) { + public function setUrl(string $url) + { $this->url = $url; return $this; } - /** - * @param string $caption - */ - public function setCaption( $caption ) { + public function setCaption(string $caption) + { $this->caption = $caption; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php b/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php index ed034b66..3949a622 100644 --- a/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/WPCLIStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class WPCLIStep implements StepDefinitionInterface { - +class WPCLIStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'wp-cli'; /** @var Progress */ @@ -14,50 +14,40 @@ class WPCLIStep implements StepDefinitionInterface { /** * The step identifier. - * * @var string */ public $step = 'wp-cli'; /** * The WP CLI command to run. - * * @var string[] */ public $command; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param mixed[] $command - */ - public function setCommand( $command ) { + public function setCommand(array $command) + { $this->command = $command; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php b/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php index 214038c7..7793e3db 100644 --- a/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php +++ b/src/WordPress/Blueprints/Model/DataClass/WordPressInstallationOptions.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class WordPressInstallationOptions { - +class WordPressInstallationOptions +{ /** @var string */ public $adminUsername; @@ -11,19 +11,15 @@ class WordPressInstallationOptions { public $adminPassword = 'admin'; - /** - * @param string $adminUsername - */ - public function setAdminUsername( $adminUsername ) { + public function setAdminUsername(string $adminUsername) + { $this->adminUsername = $adminUsername; return $this; } - /** - * @param string $adminPassword - */ - public function setAdminPassword( $adminPassword ) { + public function setAdminPassword(string $adminPassword) + { $this->adminPassword = $adminPassword; return $this; } diff --git a/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php b/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php index d2fd90de..dc1a05f8 100644 --- a/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php +++ b/src/WordPress/Blueprints/Model/DataClass/WriteFileStep.php @@ -2,8 +2,8 @@ namespace WordPress\Blueprints\Model\DataClass; -class WriteFileStep implements StepDefinitionInterface { - +class WriteFileStep implements StepDefinitionInterface +{ const DISCRIMINATOR = 'writeFile'; /** @var Progress */ @@ -17,56 +17,47 @@ class WriteFileStep implements StepDefinitionInterface { /** * The path of the file to write to - * * @var string */ public $path; /** * The data to write - * * @var string|ResourceDefinitionInterface */ public $data; - /** - * @param \WordPress\Blueprints\Model\DataClass\Progress $progress - */ - public function setProgress( $progress ) { + public function setProgress(Progress $progress) + { $this->progress = $progress; return $this; } - /** - * @param bool $continueOnError - */ - public function setContinueOnError( $continueOnError ) { + public function setContinueOnError(bool $continueOnError) + { $this->continueOnError = $continueOnError; return $this; } - /** - * @param string $step - */ - public function setStep( $step ) { + public function setStep(string $step) + { $this->step = $step; return $this; } - /** - * @param string $path - */ - public function setPath( $path ) { + public function setPath(string $path) + { $this->path = $path; return $this; } - public function setData( $data ) { + public function setData($data) + { $this->data = $data; return $this; } diff --git a/src/WordPress/Blueprints/functions.php b/src/WordPress/Blueprints/functions.php index 83d233bc..ff2240a6 100644 --- a/src/WordPress/Blueprints/functions.php +++ b/src/WordPress/Blueprints/functions.php @@ -19,10 +19,10 @@ function run_blueprint( $json, $options = array() ) { new Runtime( $documentRoot ) ); + /** @var $engine Engine */ $engine = $c['blueprint.engine']; $compiledBlueprint = $engine->parseAndCompile( $json ); - /** @var $engine Engine */ if ( $progressSubscriber ) { if ( $progressType === 'steps' ) { $compiledBlueprint->stepsProgressStage->events->addSubscriber( $progressSubscriber ); diff --git a/tests/E2E/JsonBlueprintTest.php b/tests/E2E/JsonBlueprintTest.php index 9d9f5c0f..da6e3d07 100644 --- a/tests/E2E/JsonBlueprintTest.php +++ b/tests/E2E/JsonBlueprintTest.php @@ -94,4 +94,27 @@ public function testRunningJsonBlueprintWithWordPressVersion() { // @TODO fix expected $this->assertEquals( array(), $results ); } + + public function testRunningJsonBlueprintWithSteps() { + $blueprint = '{"steps":[{"step":"mkdir","path":"dir"},{"step": "rm","path": "dir"}]}'; + + $results = run_blueprint( + $blueprint, + array( + 'environment' => ContainerBuilder::ENVIRONMENT_NATIVE, + 'documentRoot' => $this->document_root . '/new-wp', + 'progressSubscriber' => $this->subscriber, + ) + ); + + $expected = array( +// 0 => new StepSuccess(), +// 1 => new StepSuccess(), +// 2 => new StepSuccess(), +// 3 => new StepSuccess(), + ); + + // @TODO fix expected + $this->assertEquals( array(), $results ); + } } diff --git a/tests/E2E/PhpBlueprintTest.php b/tests/E2E/PhpBlueprintTest.php index 9f35abb4..0033747c 100644 --- a/tests/E2E/PhpBlueprintTest.php +++ b/tests/E2E/PhpBlueprintTest.php @@ -105,9 +105,10 @@ public function after() { public function testRunningPhpBlueprintWithSteps() { $blueprint = BlueprintBuilder::create() - ->addStep( ( new MkdirStep() )->setPath( 'dir1' ) ) - ->addStep( ( new RmStep() )->setPath( 'dir1' ) ) - ->addStep( ( new MkdirStep() )->setPath( 'dir2' ) ) + ->withWordPressVersion('https://wordpress.org/latest.zip') +// ->addStep( ( new MkdirStep() )->setPath('dir1') ) +// ->addStep( ( new RmStep() )->setPath( 'dir1' ) ) +// ->addStep( ( new MkdirStep() )->setPath( 'dir2' ) ) ->toBlueprint(); // the above does not pass validation