1
|
|
|
<?php |
2
|
|
|
use Helpers\Repository\DomainRepository; |
3
|
|
|
use Hexarchium\CoreDomain\Model\Domain\Events\DomainCreated; |
4
|
|
|
use Hexarchium\CoreDomain\UseCase\CreateDomain\UseCase; |
5
|
|
|
use PHPUnit_Framework_Assert as Assert; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Copyright |
9
|
|
|
*/ |
10
|
|
|
class DomainFeatureContext implements \Behat\Behat\Context\Context |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
/** @var UseCase */ |
13
|
|
|
private $useCase; |
14
|
|
|
|
15
|
|
|
/** @var DomainRepository */ |
16
|
|
|
private $domainRepository; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* DomainFeatureContext constructor. |
20
|
|
|
* |
21
|
|
|
* @param UseCase $useCase |
22
|
|
|
* @param DomainRepository $domainRepository |
23
|
|
|
*/ |
24
|
|
|
public function __construct(UseCase $useCase, DomainRepository $domainRepository) |
25
|
|
|
{ |
26
|
|
|
$this->useCase = $useCase; |
27
|
|
|
$this->domainRepository = $domainRepository; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @When create domain with :arg1 id |
32
|
|
|
*/ |
33
|
|
|
public function createDomainWithId($arg1) |
34
|
|
|
{ |
35
|
|
|
$command = new \Hexarchium\CoreDomain\UseCase\CreateDomain\Command($arg1); |
36
|
|
|
$this->useCase->handle($command); |
37
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @Then should see new created domain for :arg1 id |
42
|
|
|
*/ |
43
|
|
|
public function shouldSeeNewCreatedDomain($arg1) |
44
|
|
|
{ |
45
|
|
|
/** @var \Hexarchium\CoreDomain\Model\Domain\Entity\Domain $domain */ |
46
|
|
|
$domain = $this->domainRepository->offsetGet($arg1); |
47
|
|
|
Assert::assertContainsOnlyInstancesOf(DomainCreated::class, $domain->pullEvents()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @Given I have domain with :arg1 id |
52
|
|
|
*/ |
53
|
|
|
public function iHaveDomainWithId($arg1) |
54
|
|
|
{ |
55
|
|
|
$this->domainRepository->add( |
56
|
|
|
new \Hexarchium\CoreDomain\Model\Domain\Entity\Domain( |
57
|
|
|
new \Hexarchium\CoreDomain\Model\Domain\DomainId($arg1) |
58
|
|
|
) |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.