Completed
Push — master ( c15225...0916fa )
by Paweł
101:37 queued 85:36
created

iShouldBeAbleToTranslateItIn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Behat\Context\Ui\Admin;
13
14
use Behat\Behat\Context\Context;
15
use Behat\Mink\Exception\ElementNotFoundException;
16
use Sylius\Behat\Page\Admin\Taxon\CreatePage;
17
18
/**
19
 * @author Kamil Kokot <[email protected]>
20
 */
21
final class ManagingTranslatableEntitiesContext implements Context
22
{
23
    /**
24
     * @var CreatePage
25
     */
26
    private $taxonCreatePage;
27
28
    /**
29
     * @param CreatePage $taxonCreatePage
30
     */
31
    public function __construct(CreatePage $taxonCreatePage)
32
    {
33
        $this->taxonCreatePage = $taxonCreatePage;
34
    }
35
36
    /**
37
     * @When I want to create a new translatable entity
38
     */
39
    public function iWantToCreateANewTranslatableEntity()
40
    {
41
        $this->taxonCreatePage->open();
42
    }
43
44
    /**
45
     * @Then I should be able to translate it in :localeCode
46
     */
47
    public function iShouldBeAbleToTranslateItIn($localeCode)
48
    {
49
        $this->taxonCreatePage->describeItAs('Foo bar', $localeCode);
50
    }
51
52
    /**
53
     * @Then I should not be able to translate it in :localeCode
54
     */
55
    public function iShouldNotBeAbleToTranslateItIn($localeCode)
56
    {
57
        try {
58
            $this->taxonCreatePage->describeItAs('Foo bar', $localeCode);
59
        } catch (ElementNotFoundException $exception) {
60
            return;
61
        }
62
63
        throw new \DomainException(sprintf('I should not be able to translate it in "%s", but I am.', $localeCode));
64
    }
65
}
66