Completed
Push — example/managing-articles ( b68239 )
by Loïc
02:46
created

ManagingArticlesContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
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 Behat\Behat\Context\Context;
18
use Webmozart\Assert\Assert;
19
20
final class ManagingArticlesContext implements Context
21
{
22
    /**
23
     * @var IndexPage
24
     */
25
    private $indexPage;
26
27
    /**
28
     * @param IndexPage $indexPage
29
     */
30
    public function __construct(
31
        IndexPage $indexPage
32
    ) {
33
        $this->indexPage = $indexPage;
34
    }
35
36
    /**
37
     * @When I want to browse articles
38
     */
39
    public function iWantToBrowseArticles()
40
    {
41
        $this->indexPage->open();
42
    }
43
44
    /**
45
     * @Then /^there should be (\d+) articles in the list$/
46
     */
47
    public function iShouldSeeArticlesInTheList(int $number = 1): void
48
    {
49
        Assert::same($this->indexPage->countItems(), (int) $number);
50
    }
51
52
    /**
53
     * @Then I should (also )see the article :title in the list
54
     */
55
    public function theArticleShouldAppearInTheWebsite($title)
56
    {
57
        $this->indexPage->open();
58
59
        Assert::true($this->indexPage->isSingleResourceOnPage(['title' => $title]));
60
    }
61
}
62