Code Duplication    Length = 47-49 lines in 2 locations

features/bootstrap/ModelFeatureContext.php 1 location

@@ 13-59 (lines=47) @@
10
/**
11
 * Copyright
12
 */
13
class ModelFeatureContext implements \Behat\Behat\Context\Context
14
{
15
    /** @var  DomainRepository */
16
    private $domainRepository;
17
    /** @var UseCase */
18
    private $useCase;
19
20
    /**
21
     * ModelFeatureContext constructor.
22
     *
23
     * @param UseCase $useCase
24
     * @param DomainRepository $domainRepository
25
     */
26
    public function __construct(UseCase $useCase, DomainRepository $domainRepository)
27
    {
28
        $this->domainRepository = $domainRepository;
29
        $this->useCase = $useCase;
30
    }
31
32
    /**
33
     * @When I create model with :arg1 id for :arg2 domain
34
     */
35
    public function iCreateModelWithIdForDomain($arg1, $arg2)
36
    {
37
        $command = new Command(
38
            new ModelId($arg1),
39
            new DomainId($arg2)
40
        );
41
        $this->useCase->handle($command);
42
    }
43
44
    /**
45
     * @Then I should see new model in :arg1 domain
46
     */
47
    public function iShouldSeeAddedToDomain($arg1)
48
    {
49
        /** @var \Hexarchium\CoreDomain\Model\Domain\Entity\Domain $domain */
50
        $domain = $this->domainRepository->getById(new DomainId($arg1));
51
        $counter = 0;
52
        foreach ($domain->pullEvents() as $event) {
53
            if ($event instanceof ModelAdded) {
54
                $counter++;
55
            }
56
        }
57
        Assert::assertTrue($counter > 0);
58
    }
59
}
60

features/bootstrap/UseCaseFeatureContext.php 1 location

@@ 12-60 (lines=49) @@
9
/**
10
 * Copyright
11
 */
12
class UseCaseFeatureContext implements \Behat\Behat\Context\Context
13
{
14
    /** @var UseCase */
15
    private $useCase;
16
17
    /** @var DomainRepositoryInterface */
18
    private $domainRepository;
19
20
    /**
21
     * UseCaseFeatureContext constructor.
22
     *
23
     * @param UseCase $useCase
24
     * @param DomainRepositoryInterface $domainRepository
25
     */
26
    public function __construct(UseCase $useCase, DomainRepositoryInterface $domainRepository)
27
    {
28
        $this->useCase = $useCase;
29
        $this->domainRepository = $domainRepository;
30
    }
31
32
    /**
33
     * @When I create usecase with :arg1 and type :arg2 id for :arg3 domain
34
     */
35
    public function iCreateUsecaseWithIdForDomain($arg1, $arg2, $arg3)
36
    {
37
        $command = new Command(
38
            new UseCaseId($arg1),
39
            new DomainId($arg3),
40
            $arg2
41
        );
42
        $this->useCase->handle($command);
43
    }
44
45
    /**
46
     * @Then I should see new usecase in :arg1 domain
47
     */
48
    public function iShouldSeeNewUsecaseInDomain($arg1)
49
    {
50
        /** @var \Hexarchium\CoreDomain\Model\Domain\Entity\Domain $domain */
51
        $domain = $this->domainRepository->getById(new DomainId($arg1));
52
        $counter = 0;
53
        foreach ($domain->pullEvents() as $event) {
54
            if ($event instanceof \Hexarchium\CoreDomain\Model\Domain\Events\UseCaseAdded) {
55
                $counter++;
56
            }
57
        }
58
        Assert::assertTrue($counter > 0);
59
    }
60
}
61