Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

[WIP] Extensions catalogue #36

Merged
merged 37 commits into from
Mar 11, 2015
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d348b0d
Describe extensions cataloguisation feature
everzet Jan 18, 2015
1f466aa
Initialize extension maintainer context suite
everzet Jan 18, 2015
64cbad4
Append snippets for the first extension scenario
everzet Jan 18, 2015
a849db8
Add missing "no extensions were created" scenario
everzet Jan 18, 2015
d217453
Move release-related transformations into ReleaseTransformations
everzet Jan 18, 2015
a2e9fb0
Define first extension step and introduce Extension
everzet Jan 18, 2015
e3d097f
Make first extensions definition green
everzet Jan 18, 2015
5db1abf
Move transformation traits into ContextHelper namespace
everzet Jan 18, 2015
eaac914
Move traits include above context properties
everzet Jan 18, 2015
34cb206
Implement second extensions step definition
everzet Jan 18, 2015
2df1ff0
Define `extension catalogue should contain extension` step
everzet Jan 18, 2015
11b318f
Replace fatal error with meaningful exception
everzet Jan 18, 2015
cefdbf5
Slightly reword scenario
everzet Jan 18, 2015
db42da0
Add scenario that cowers release with docs, but no extensions
everzet Jan 18, 2015
5668f30
Introduce extension Repository
everzet Jan 18, 2015
f0f3efa
Introduce ExtensionCataloguer and Extractor
everzet Jan 18, 2015
8578b7c
Introduce Fake implementations to progress with the scenario
everzet Jan 18, 2015
18c3a2a
Fix wrong step definition
everzet Jan 18, 2015
32dae58
Implement ExtensionCatalogue::getAll()
everzet Jan 18, 2015
570aa80
Implement last step definition
everzet Jan 18, 2015
910dce0
Fix broken repository and make last scenario step pass
everzet Jan 18, 2015
468550c
Remove useless license block for now
everzet Jan 18, 2015
e67c1b8
Add missing stepdef for third extension scenario
everzet Jan 18, 2015
5333268
Add missing stepdefs for forth scenario
everzet Jan 18, 2015
c0e2b87
Add missing stepdefs for the last extensions scenario
everzet Jan 18, 2015
44920ee
Extract all transformations into dictionary traits
everzet Jan 18, 2015
052e5fd
Rename Dictionaries to Transformation
everzet Jan 18, 2015
a62a616
Add missing doc blocks to the ExtensionCatalogue
everzet Jan 20, 2015
ddfb377
Refactor domain contexts for better readability
everzet Jan 20, 2015
1b2662a
Introduce ExtensionUIContext and extract ReleaseUIContext
everzet Jan 26, 2015
0ebecf4
Move Smoke contexts into the Smoke namespace
everzet Jan 26, 2015
392a45d
Fix broken path
everzet Feb 14, 2015
7398291
Cleanup behat.yml
everzet Feb 14, 2015
ed1d994
Improve behat.yml readability
everzet Feb 14, 2015
3c2f399
Support extensions with space between name and colon
everzet Mar 11, 2015
8cea661
Make extension scenarios uncritical to make feature merge-able
everzet Mar 11, 2015
250d86e
Fix indentation
everzet Mar 11, 2015
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
12 changes: 11 additions & 1 deletion behat.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
default:
autoload: false

suites:
documentation_contributor:
contexts: [ 'DocumentationContributorContext' ]
filters: { role: 'documentation contributor' }

extension_maintainer:
contexts: [ 'ExtensionMaintainerContext' ]
filters: { role: 'extension maintainer' }

smoke:
contexts:
- DocumentationUIContext:
- Smoke\ReleaseUIContext
- Smoke\ExtensionUIContext:
client: @github.client
- Smoke\DocumentationUIContext:
publisher: @documentation.publisher
client: @github.client

filters: { tags: 'critical' }

extensions:
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"autoload-dev": {
"psr-4": {
"spec\\Behat\\Borg\\": "spec/",
"tests\\Behat\\Borg\\": "tests/"
"tests\\Behat\\Borg\\": "tests/",
"": "features/bootstrap/"
}
},

Expand Down
12 changes: 5 additions & 7 deletions features/bootstrap/DocumentationContributorContext.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Borg\Application\Infrastructure\Documentation\PersistedObjectsRepository;
use Behat\Borg\Documentation\Page\PageId;
use Behat\Borg\Documentation\ProjectDocumentationId;
Expand All @@ -25,13 +24,14 @@
/**
* Describes documentation-related features from the documentation manager context.
*/
class DocumentationContributorContext implements Context, SnippetAcceptingContext
class DocumentationContributorContext implements Context
{
use Transformation\Release;
use Transformation\Documentation;

private $releaseManager;
private $documenter;

use DocumentationTransformations;

/**
* Initializes context.
*/
Expand Down Expand Up @@ -68,9 +68,7 @@ public function packageWasDocumented(FakeRepository $repository, Package $packag
/**
* @Given :package version :version was not documented
*/
public function packageWasNotDocumented()
{
}
public function packageWasNotDocumented() { }

/**
* @When I release :repository version :version
Expand Down
95 changes: 95 additions & 0 deletions features/bootstrap/ExtensionMaintainerContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

use Behat\Behat\Context\Context;
use Behat\Borg\Application\Infrastructure\Extension\PersistedObjectsRepository;
use Behat\Borg\ExtensionCatalogue;
use Behat\Borg\ExtensionPackage\ExtensionCataloguer;
use Behat\Borg\Package\Package;
use Behat\Borg\Package\ReleasePackager;
use Behat\Borg\Release\Release;
use Behat\Borg\Release\ReleaseDownloader;
use Behat\Borg\Release\Version;
use Behat\Borg\ReleaseManager;
use Fake\Extension\FakeExtension;
use Fake\Extension\FakeExtractor;
use Fake\Package\FakePackageFinder;
use Fake\Release\FakeDownloader;
use Fake\Release\FakeRepository;
use PHPUnit_Framework_Assert as PHPUnit;

/**
* Defines application features from the specific context.
*/
class ExtensionMaintainerContext implements Context
{
use Transformation\Release;
use Transformation\Extension;
use Transformation\Documentation;

private $releaseManager;
private $catalogue;

/**
* Initializes context.
*/
public function __construct()
{
$this->releaseManager = new ReleaseManager();
$this->catalogue = new ExtensionCatalogue(new PersistedObjectsRepository(null));

$releaseDownloader = new ReleaseDownloader(new FakeDownloader());
$releasePackager = new ReleasePackager(new FakePackageFinder());
$extensionCataloguer = new ExtensionCataloguer(new FakeExtractor(), $this->catalogue);

$this->releaseManager->registerListener($releaseDownloader);
$releaseDownloader->registerListener($releasePackager);
$releasePackager->registerListener($extensionCataloguer);
}

/**
* @Given :extension extension was created in :repository
*/
public function extensionWasCreated(FakeRepository $repository, FakeExtension $extension)
{
$repository->createExtension($extension);
}

/**
* @Given extension was not created in :repository
*/
public function extensionWasNotCreated() { }

/**
* @Given :package version :version was documented in :repository
*/
public function packageWasDocumented(FakeRepository $repository, Package $package, Version $version)
{
$repository->documentPackage($package, $version, new DateTimeImmutable());
}

/**
* @When I release :repository version :version
*/
public function iReleaseVersion(FakeRepository $repository, Version $version)
{
$this->releaseManager->release(new Release($repository, $version));
}

/**
* @Then the extension catalogue should contain :count extension(s)
* @Then the extension catalogue should still contain :count extension(s)
* @Then the extension catalogue should be empty
*/
public function extensionCatalogueShouldHaveCount($count = 0)
{
PHPUnit::assertCount($count, $this->catalogue->getAll());
}

/**
* @Then :extensionName extension should be in the catalogue
*/
public function extensionShouldBeInCatalogue($extensionName)
{
PHPUnit::assertNotNull($this->catalogue->find($extensionName), 'Extension not found.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Behat\Borg\Release\Downloader\Download;

interface DocumentedDownload extends Download
interface DocumentationDownload extends Download
{
public function getSource();
public function source();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
use Behat\Borg\Release\Downloader\Download;
use Behat\Borg\Release\Release;
use DateTimeImmutable;
use Fake\Package\PackagedDownload;
use Fake\Release\FakeDownload;
use Fake\Package\FakePackageDownload;
use Fake\Package\PackageDownload;

final class FakeDocumentedDownload implements Download, DocumentedDownload, PackagedDownload
final class FakeDocumentationDownload implements Download, DocumentationDownload, PackageDownload
{
private $original;
private $package;
private $source;

public function __construct(Release $release, DateTimeImmutable $time, Package $package, Source $source)
{
$this->original = new FakeDownload($release, $time);
$this->original = new FakePackageDownload($release, $time, $package);
$this->source = $source;
$this->package = $package;
}

public function version()
Expand Down Expand Up @@ -48,12 +46,12 @@ public function filePath($relativePath)
return $this->original->filePath($relativePath);
}

public function getPackage()
public function package()
{
return $this->package;
return $this->original->package();
}

public function getSource()
public function source()
{
return $this->source;
}
Expand Down
4 changes: 2 additions & 2 deletions features/bootstrap/Fake/Documentation/FakeSourceFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ final class FakeSourceFinder implements SourceFinder
{
public function find(Download $download)
{
if ($download instanceof DocumentedDownload) {
return $download->getSource();
if ($download instanceof DocumentationDownload) {
return $download->source();
}

return null;
Expand Down
40 changes: 40 additions & 0 deletions features/bootstrap/Fake/Extension/FakeExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Fake\Extension;

use Behat\Borg\Extension\Extension;
use Behat\Borg\Package\Package;

final class FakeExtension implements Extension, Package
{
private $name;

public static function named($name)
{
if (2 !== count(explode('/', $name))) {
throw new \InvalidArgumentException('Extension should include organisation and name.');
}

$package = new FakeExtension();
$package->name = $name;

return $package;
}

public function organisationName()
{
return explode('/', $this->name)[0];
}

public function name()
{
return explode('/', $this->name)[1];
}

public function __toString()
{
return $this->name;
}

private function __construct() { }
}
18 changes: 18 additions & 0 deletions features/bootstrap/Fake/Extension/FakeExtractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Fake\Extension;

use Behat\Borg\Extension\Extractor\Extractor;
use Behat\Borg\Package\Package;

final class FakeExtractor implements Extractor
{
public function extract(Package $package)
{
if ($package instanceof FakeExtension) {
return $package;
}

return null;
}
}
51 changes: 51 additions & 0 deletions features/bootstrap/Fake/Package/FakePackageDownload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Fake\Package;

use Behat\Borg\Package\Package;
use Behat\Borg\Release\Downloader\Download;
use Behat\Borg\Release\Release;
use DateTimeImmutable;
use Fake\Release\FakeDownload;

final class FakePackageDownload implements Download, PackageDownload
{
private $original;
private $package;

public function __construct(Release $release, DateTimeImmutable $time, Package $package)
{
$this->original = new FakeDownload($release, $time);
$this->package = $package;
}

public function version()
{
return $this->original->version();
}

public function releasedAt()
{
return $this->original->releasedAt();
}

public function path()
{
return $this->original->path();
}

public function hasFile($relativePath)
{
return $this->original->hasFile($relativePath);
}

public function filePath($relativePath)
{
return $this->original->filePath($relativePath);
}

public function package()
{
return $this->package;
}
}
4 changes: 2 additions & 2 deletions features/bootstrap/Fake/Package/FakePackageFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ final class FakePackageFinder implements PackageFinder
{
public function find(Download $download)
{
if ($download instanceof PackagedDownload) {
return $download->getPackage();
if ($download instanceof PackageDownload) {
return $download->package();
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Behat\Borg\Release\Downloader\Download;

interface PackagedDownload extends Download
interface PackageDownload extends Download
{
public function getPackage();
public function package();
}
Loading