Add custom tests

This commit is contained in:
Oliver Davies 2016-06-15 08:36:06 +01:00
parent 8c11fb9195
commit 928dbde30f
6 changed files with 37 additions and 14 deletions

View file

@ -3,9 +3,3 @@ default:
Behat\MinkExtension:
base_url: http://127.0.0.1:8000
goutte: ~
suites:
default:
contexts:
- FeatureContext
- Behat\MinkExtension\Context\MinkContext

View file

@ -3,12 +3,14 @@ Feature: Blog
Scenario:
Given I am on "/blog"
Then the response status code should be 200
And the ".nav li.active a" element should contain "Blog"
And the page title should be "Blog"
And the active menu link should be "Blog"
Scenario:
Given I am on "/blog/simplifying-drupal-migrations-with-xautoload"
Then the response status code should be 200
And the ".nav li.active a" element should contain "Blog"
And the page title should be "Simplifying Drupal Migrations with xautoload"
And the active menu link should be "Blog"
Scenario:
Given I am on "/"

View file

@ -1,14 +1,16 @@
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
/**
* Defines application features from the specific context.
*/
class FeatureContext implements Context, SnippetAcceptingContext
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext
{
/**
* Initializes context.
@ -20,4 +22,28 @@ class FeatureContext implements Context, SnippetAcceptingContext
public function __construct()
{
}
/**
* @Then the active menu link should be :text
*/
public function theActiveMenuLinkShouldBe($text)
{
return $this->assertElementContains('.navbar .active a', $text);
}
/**
* @Then the page title should be :text
*/
public function thePageTitleShouldBe($text)
{
return $this->assertElementContainsText('title', $text);
}
/**
* @Then the page title should not be :text
*/
public function thePageTitleShouldNotBe($text)
{
return $this->assertElementNotContainsText('title', $text);
}
}

View file

@ -3,4 +3,4 @@ Feature: Contact page
Scenario:
Given I am on "/contact"
Then the response status code should be 200
And the ".nav li.active a" element should contain "Contact"
And the active menu link should be "Contact"

View file

@ -3,4 +3,5 @@ Feature: Experience page
Scenario:
Given I am on "/experience"
Then the response status code should be 200
And the ".nav li.active a" element should contain "Experience"
And the page title should be "Experience"
And the active menu link should be "Experience"

View file

@ -6,7 +6,7 @@ Feature: Home
Scenario:
Given I am on the homepage
Then the response status code should be 200
And the ".nav li.active a" element should contain "About"
And I should see "Im a Web Developer and System Administrator based in Wales, UK."
And the "title" element should contain "Web Developer, System Administrator - PHP, Drupal, Symfony, Linux | Oliver Davies"
And the "title" element should not contain "About | Oliver Davies"
And the active menu link should be "About"
And the page title should be "Web Developer, System Administrator - PHP, Drupal, Symfony, Linux | Oliver Davies"
And the page title should not be "About | Oliver Davies"