iAccessStaticContentWithName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Tests\Lakion\CmsPlugin\Behat\Context\Ui\Shop;
4
5
use Behat\Behat\Context\Context;
6
use Tests\Lakion\CmsPlugin\Behat\Page\Shop\StaticContentPageInterface;
7
use Lakion\CmsPlugin\Document\StaticContent;
8
9
final class StaticContentContext implements Context
10
{
11
    /**
12
     * @var StaticContentPageInterface
13
     */
14
    private $staticContentPage;
15
16
    /**
17
     * @param StaticContentPageInterface $staticContentPage
18
     */
19
    public function __construct(StaticContentPageInterface $staticContentPage)
20
    {
21
        $this->staticContentPage = $staticContentPage;
22
    }
23
24
    /**
25
     * @When I access static content with name :name
26
     */
27
    public function iAccessStaticContentWithName($name)
28
    {
29
        $this->staticContentPage->tryToOpen(['name' => $name]);
30
    }
31
32
    /**
33
     * @Then /^I should see (that static content)$/
34
     */
35
    public function iShouldSeeThatStaticContent(StaticContent $staticContent)
36
    {
37
        $this->staticContentPage->assertPageHasContent($staticContent);
38
    }
39
40
    /**
41
     * @Then /^(that static content) should not be found there$/
42
     */
43
    public function thatPageShouldNotBeFound(StaticContent $staticContent)
44
    {
45
        try {
46
            $this->iShouldSeeThatStaticContent($staticContent);
47
        } catch (\Exception $exception) {
48
            return;
49
        }
50
51
        throw new \DomainException(sprintf('Static content "%s" was found!', $staticContent->getTitle()));
52
    }
53
}
54