Completed
Push — example/managing-articles ( b68239...b7fbb8 )
by Loïc
02:19 queued 02:15
created

ManagingArticlesContext::iSpecifyItsEmailAs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of AppName.
5
 *
6
 * (c) Monofony
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
declare(strict_types=1);
13
14
namespace App\Behat\Context\Ui\Backend;
15
16
use App\Behat\Page\Backend\Article\IndexPage;
17
use App\Behat\Page\Backend\Article\CreatePage;
18
use Behat\Behat\Context\Context;
19
use Webmozart\Assert\Assert;
20
21
final class ManagingArticlesContext implements Context
22
{
23
    /**
24
     * @var CreatePage
25
     */
26
    private $createPage;
27
28
    /**
29
     * @var IndexPage
30
     */
31
    private $indexPage;
32
33
    /**
34
     * @param CreatePage $createPage
35
     * @param IndexPage  $indexPage
36
     */
37
    public function __construct(
38
        CreatePage $createPage,
39
        IndexPage $indexPage
40
    ) {
41
        $this->createPage = $createPage;
42
        $this->indexPage = $indexPage;
43
    }
44
45
    /**
46
     * @Given I want to create a new article
47
     */
48
    public function iWantToCreateANewArticle()
49
    {
50
        $this->createPage->open();
51
    }
52
53
    /**
54
     * @When I want to browse articles
55
     */
56
    public function iWantToBrowseArticles()
57
    {
58
        $this->indexPage->open();
59
    }
60
61
    /**
62
     * @When I specify its title as :title
63
     * @When I do not specify its title
64
     */
65
    public function iSpecifyItsEmailAs($title = null)
66
    {
67
        $this->createPage->specifyTitle($title);
68
    }
69
70
    /**
71
     * @When I add it
72
     * @When I try to add it
73
     */
74
    public function iAddIt()
75
    {
76
        $this->createPage->create();
77
    }
78
79
    /**
80
     * @Then /^there should be (\d+) articles in the list$/
81
     */
82
    public function iShouldSeeArticlesInTheList(int $number = 1): void
83
    {
84
        Assert::same($this->indexPage->countItems(), (int) $number);
85
    }
86
87
    /**
88
     * @Then I should (also )see the article :title in the list
89
     * @Then the article :title should appear in the website
90
     */
91
    public function theArticleShouldAppearInTheWebsite($title)
92
    {
93
        $this->indexPage->open();
94
95
        Assert::true($this->indexPage->isSingleResourceOnPage(['title' => $title]));
96
    }
97
}
98