Passed
Pull Request — master (#202)
by
unknown
02:51
created

theTitleShouldNotBeLongerThan()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Behatch\Context;
4
5
use Behat\Gherkin\Node\TableNode;
6
use Behat\Mink\Exception\ExpectationException;
7
use Behat\Mink\Exception\ResponseTextException;
8
use Behat\Mink\Exception\ElementNotFoundException;
9
use WebDriver\Exception\StaleElementReference;
10
use Behat\Behat\Tester\Exception\PendingException;
11
12
class AccesibilityContext extends BaseContext
13
{
14
    /**
15
     * @Then all images should have an alt attribute
16
     */
17 View Code Duplication
    public function allImagesShouldHaveAnAltAttribute()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        $images = $this->getSession()->getPage()->findAll('xpath', '//img[not(@alt)]');
20
        if ($images !== null) {
21
            throw new \Exception("There are images without an alt attribute");
22
        } 
23
    }
24
25
    /**
26
     * @Then the title should not be longer than :arg1
27
     */
28
    public function theTitleShouldNotBeLongerThan($arg1)
29
    {
30
        $title = $this->getSession()->getPage()->find('css', 'h1')->getText();
31
        if (strlen($title) > $arg1) {
32
            throw new \Exception("The h1 title is more than '$arg1' characters long");
33
        }
34
    }
35
36
    /**
37
     * @Then all tables should have a table header
38
     */
39 View Code Duplication
    public function allTablesShouldHaveATableHeader()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(th)]');
42
        if ($tables !== null) {
43
            throw new \Exception("There are tables without a table header");
44
        }
45
    }
46
47
    /**
48
     * @Then all tables should have at least one data row
49
     */
50 View Code Duplication
    public function allTablesShouldHaveAtLeastOneDataRow()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(td)]');
53
        if ($tables !== null) {
54
            throw new \Exception("There are tables without a data row");
55
        }
56
    }    
57
}
58