Passed
Pull Request — master (#12)
by Robbie
02:00
created

iShouldSeeTheThumbnailImageForBlock()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
namespace SilverStripe\ElementalBannerBlock\Tests\Behat\Context;
3
4
use Behat\Mink\Element\NodeElement;
0 ignored issues
show
Bug introduced by
The type Behat\Mink\Element\NodeElement was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use DNADesign\Elemental\Tests\Behat\Context\FeatureContext as BaseFeatureContext;
6
7
class FeatureContext extends BaseFeatureContext
8
{
9
    /**
10
     * @Then /^I should( not |\s+)see the thumbnail image for block (\d+)$/i
11
     *
12
     * @param string $negative
13
     * @param int $position
14
     *
15
     */
16
    public function iShouldSeeTheThumbnailImageForBlock($negative, $position)
17
    {
18
        $iShouldNotSee = $negative === ' not ';
19
20
        $thumbnailImage = $this->findThumbnailImage($position);
21
22
        if ($iShouldNotSee) {
23
            assertNull($thumbnailImage, 'Thumbnail image displayed (but shouldn\'t)');
24
        } else {
25
            assertNotNull($thumbnailImage, 'Thumbnail image not displayed (but should be)');
26
        }
27
    }
28
29
30
    /**
31
     * Returns the thumbnail image for a specific block if it exists
32
     *
33
     * @param int $position
34
     * @return NodeElement|null
35
     */
36
    protected function findThumbnailImage($position)
37
    {
38
        $block = $this->getSpecificBlock($position);
39
        assertNotNull($block, 'Block ' . $position . ' was not found in the page.');
40
41
        $thumbnail = $block->find(
42
            'css',
43
            '.element-editor-content .element-editor-summary .element-editor-summary__thumbnail-image'
44
        );
45
46
        return $thumbnail;
47
    }
48
}
49