Completed
Push — master ( 2c8981...1ecbe4 )
by Kamil
23:19
created

ManagingProductsContext::productShouldNotExist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
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 Sylius\Behat\Page\Admin\Product\IndexPageInterface;
16
use Sylius\Behat\Page\Admin\Product\ShowPageInterface as AdminProductShowPageInterface;
17
use Sylius\Component\Core\Model\ProductInterface;
18
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
19
20
/**
21
 * @author Kamil Kokot <[email protected]>
22
 * @author Magdalena Banasiak <[email protected]>
23
 */
24
final class ManagingProductsContext implements Context
25
{
26
    /**
27
     * @var SharedStorageInterface
28
     */
29
    private $sharedStorage;
30
31
    /**
32
     * @var AdminProductShowPageInterface
33
     */
34
    private $showPage;
35
36
    /**
37
     * @var IndexPageInterface
38
     */
39
    private $indexPage;
40
41
42
    public function __construct(
43
        SharedStorageInterface $sharedStorage,
44
        AdminProductShowPageInterface $showPage,
45
        IndexPageInterface $indexPage
46
    ) {
47
        $this->sharedStorage = $sharedStorage;
48
        $this->showPage = $showPage;
49
        $this->indexPage = $indexPage;
50
    }
51
52
    /**
53
     * @When I delete the :product product
54
     */
55
    public function iDeleteProduct(ProductInterface $product)
56
    {
57
        $this->showPage->open(['id' => $product->getId()]);
58
59
        $this->showPage->deleteProduct();
60
61
        $this->sharedStorage->set('product', $product);
62
    }
63
64
    /**
65
     * @Then /^(this product) should not exist in the product catalog$/
66
     */
67
    public function productShouldNotExist(ProductInterface $product)
68
    {
69
        $this->indexPage->open();
70
71
        expect($this->indexPage->isThereProduct($product))->toBe(false);
72
    }
73
}
74