Completed
Push — symfony3 ( 405d0c...88ded0 )
by Kamil
32:03 queued 12:32
created

HomepageContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A iCheckLatestProducts() 0 4 1
A iShouldSeeProductsInTheList() 0 10 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\Shop;
13
14
use Behat\Behat\Context\Context;
15
use Sylius\Behat\Page\Shop\HomePageInterface;
16
use Webmozart\Assert\Assert;
17
18
/**
19
 * @author Łukasz Chruściel <[email protected]>
20
 */
21
final class HomepageContext implements Context
22
{
23
    /**
24
     * @var HomePageInterface
25
     */
26
    private $homePage;
27
28
    /**
29
     * @param HomePageInterface $homepage
30
     */
31
    public function __construct(HomePageInterface $homepage)
32
    {
33
        $this->homePage = $homepage;
34
    }
35
36
    /**
37
     * @When I check latest products
38
     */
39
    public function iCheckLatestProducts()
40
    {
41
        $this->homePage->open();
42
    }
43
44
    /**
45
     * @Then I should see :numberOfProducts products in the list
46
     */
47
    public function iShouldSeeProductsInTheList($numberOfProducts)
48
    {
49
        $foundProductsNames = $this->homePage->getLatestProductsNames();
50
51
        Assert::same(
52
            (int) $numberOfProducts,
53
            count($foundProductsNames),
54
            '%d rows with products should appear on page, %d rows has been found'
55
        );
56
    }
57
}
58