Completed
Push — master ( 133b57...4c004c )
by Kamil
20:32
created

iShouldBeNotifiedAboutSuccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 1
f 0
cc 1
eloc 3
nc 1
nop 0
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 Sylius\Behat\Page\Admin\Country\CreatePageInterface;
16
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
17
use Sylius\Component\Addressing\Model\CountryInterface;
18
19
/**
20
 * @author Arkadiusz Krakowiak <[email protected]>
21
 */
22
final class ManagingCountriesContext implements Context
23
{
24
    /**
25
     * @var IndexPageInterface
26
     */
27
    private $countryIndexPage;
28
29
    /**
30
     * @var CreatePageInterface
31
     */
32
    private $countryCreatePage;
33
34
    /**
35
     * @param IndexPageInterface $countryIndexPage
36
     * @param CreatePageInterface $countryCreatePage
37
     */
38
    public function __construct(
39
        IndexPageInterface $countryIndexPage,
40
        CreatePageInterface $countryCreatePage
41
    ) {
42
        $this->countryIndexPage = $countryIndexPage;
43
        $this->countryCreatePage = $countryCreatePage;
44
    }
45
46
    /**
47
     * @Given I want to create new country
48
     */
49
    public function iWantToCreateNewCountry()
50
    {
51
        $this->countryCreatePage->open();
52
    }
53
54
    /**
55
     * @When /^I choose "([^"]*)"$/
56
     */
57
    public function iChoose($name)
58
    {
59
        $this->countryCreatePage->chooseName($name);
60
    }
61
62
    /**
63
     * @When I add it
64
     */
65
    public function iAddIt()
66
    {
67
        $this->countryCreatePage->create();
68
    }
69
70
    /**
71
     * @Then I should be notified about success
72
     */
73
    public function iShouldBeNotifiedAboutSuccess()
74
    {
75
        expect($this->countryIndexPage->hasSuccessMessage())->toBe(true);
76
        expect($this->countryIndexPage->isSuccessfullyCreated())->toBe(true);
77
    }
78
79
    /**
80
     * @Given /^(country "([^"]*)") should appear in the store$/
81
     */
82
    public function countryWithNameShouldAppearInTheStore(CountryInterface $country)
83
    {
84
        expect($this->countryIndexPage->isResourceOnPage(['code' => $country->getCode()]))->toBe(true);
85
    }
86
}
87