Completed
Branch master (6ff579)
by Tomasz
06:50 queued 03:50
created

ModelFeatureContext   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A iCreateModelWithIdForDomain() 0 10 1
A iShouldSeeAddedToDomain() 0 12 3
1
<?php
2
use Helpers\Repository\DomainRepository;
3
use Hexarchium\CoreDomain\Model\Domain\DomainId;
4
use Hexarchium\CoreDomain\Model\Domain\Events\ModelAdded;
5
use PHPUnit_Framework_Assert as Assert;
6
7
/**
8
 * Copyright
9
 */
10
class ModelFeatureContext 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  DomainRepository */
13
    private $domainRepository;
14
15
    /**
16
     * ModelFeatureContext constructor.
17
     *
18
     * @param DomainRepository $domainRepository
19
     */
20
    public function __construct(DomainRepository $domainRepository)
21
    {
22
        $this->domainRepository = $domainRepository;
23
    }
24
25
    /**
26
     * @When I create model with :arg1 id for :arg2 domain
27
     */
28
    public function iCreateModelWithIdForDomain($arg1, $arg2)
29
    {
30
        $domainId = new DomainId($arg2);
31
        $domain = $this->domainRepository->getById($domainId);
32
        $domain->addModel(
33
            new \Hexarchium\CoreDomain\Model\Domain\Entity\Model(
34
                new \Hexarchium\CoreDomain\Model\Domain\Model\ModelId($domainId, $arg1)
35
            )
36
        );
37
    }
38
39
    /**
40
     * @Then I should see new model in :arg1 domain
41
     */
42
    public function iShouldSeeAddedToDomain($arg1)
43
    {
44
        /** @var \Hexarchium\CoreDomain\Model\Domain\Entity\Domain $domain */
45
        $domain = $this->domainRepository->getById(new DomainId($arg1));
46
        $counter = 0;
47
        foreach ($domain->pullEvents() as $event) {
48
            if ($event instanceof ModelAdded) {
49
                $counter++;
50
            }
51
        }
52
        Assert::assertTrue($counter > 0);
53
    }
54
}
55