-
Notifications
You must be signed in to change notification settings - Fork 204
added a few accesibility checks. more to come. #202
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| namespace Sanpi\Behatch\Context; | ||
|
|
||
| use Behat\Gherkin\Node\TableNode; | ||
| use Behat\Mink\Exception\ExpectationException; | ||
| use Behat\Mink\Exception\ResponseTextException; | ||
| use Behat\Mink\Exception\ElementNotFoundException; | ||
|
|
||
| class AccesibilityContext extends BaseContext | ||
| { | ||
|
|
||
| public function __construct() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No empty construct.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| { | ||
| } | ||
|
|
||
| /** | ||
| * @Then all images should have an alt attribute | ||
| */ | ||
| public function allImagesShouldHaveAnAltAttribute() | ||
| { | ||
| $images = $this->getSession()->getPage()->findAll('xpath', '//img[not(@alt)]'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, could you tell me this would refer to test image without alt? |
||
| if ($images != null) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use strict (
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| throw new \Exception("There are images without an alt attribute"); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @Then the title should not be longer than :arg1 | ||
| */ | ||
| public function theTitleShouldNotBeLongerThan($arg1) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use explicite argument name, like |
||
| { | ||
| $title = $this->getSession()->getPage()->find('css', 'h1')->getText(); | ||
| if (strlen($title) > $arg1) { | ||
| throw new \Exception("The h1 title is more than '$arg1' characters long"); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @Then all tables should have a table header | ||
| */ | ||
| public function allTablesShouldHaveATableHeader() | ||
| { | ||
| $tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(th)]'); | ||
| if ($tables != null) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use strict (
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| throw new \Exception("There are tables without a table header"); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the last version, the right namespace is
Behatch\Context.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also test added