Skip to content

Add e2e tests #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/blueprint_compiling.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion examples/json_string_compiling.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]}';
Expand Down
1 change: 1 addition & 0 deletions src/WordPress/Blueprints/BlueprintParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
29 changes: 10 additions & 19 deletions src/WordPress/Blueprints/Model/DataClass/ActivatePluginStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace WordPress\Blueprints\Model\DataClass;

class ActivatePluginStep implements StepDefinitionInterface {

class ActivatePluginStep implements StepDefinitionInterface
{
const DISCRIMINATOR = 'activatePlugin';

/** @var Progress */
Expand All @@ -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;
}
Expand Down
29 changes: 10 additions & 19 deletions src/WordPress/Blueprints/Model/DataClass/ActivateThemeStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace WordPress\Blueprints\Model\DataClass;

class ActivateThemeStep implements StepDefinitionInterface {

class ActivateThemeStep implements StepDefinitionInterface
{
const DISCRIMINATOR = 'activateTheme';

/** @var Progress */
Expand All @@ -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;
}
Expand Down
65 changes: 22 additions & 43 deletions src/WordPress/Blueprints/Model/DataClass/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
17 changes: 6 additions & 11 deletions src/WordPress/Blueprints/Model/DataClass/BlueprintOnBoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
18 changes: 6 additions & 12 deletions src/WordPress/Blueprints/Model/DataClass/CorePluginResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading