Passed
Push — master ( 7b7e33...6ff579 )
by Tomasz
04:38
created

DomainFeatureContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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