Skip to content
Browse files

Implement custom Mink step to check the favicon.

  • Loading branch information...
1 parent f98d489 commit 32439311ad26b7f89869590f8ca488bfb7daa135 @smerrill smerrill committed Aug 11, 2012
Showing with 20 additions and 3 deletions.
  1. +20 −3 features/bootstrap/FeatureContext.php
View
23 features/bootstrap/FeatureContext.php
@@ -7,7 +7,8 @@
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
-Behat\Behat\Exception\PendingException;
+Behat\Behat\Exception\PendingException,
+Behat\Behat\Context\Step;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
@@ -21,7 +22,7 @@
/**
* Features context.
*/
-class FeatureContext extends BehatContext {
+class FeatureContext extends Behat\MinkExtension\Context\MinkContext {
/**
* Initializes context.
* Every scenario gets it's own context object.
@@ -30,6 +31,22 @@ class FeatureContext extends BehatContext {
* context parameters (set them up through behat.yml)
*/
public function __construct(array $parameters) {
- $this->useContext('mink', new MinkContext($kernel));
+ }
+
+ /**
+ * @Then /^the favicon should be found$/
+ */
+ public function theFaviconShouldBeFound() {
+ if ($favicon_link = $this->getSession()->getPage()->find('css', 'link[rel="shortcut icon"]')) {
+ $favicon_url = $favicon_link->getAttribute('href');
+ }
+ else {
+ $favicon_url = "/favicon.ico";
+ }
+
+ return array(
+ new Step\Given('I go to "' . $favicon_url . '"'),
+ new Step\Then('the response status code should not be 404'),
+ );
}
}

0 comments on commit 3243931

Please sign in to comment.
Something went wrong with that request. Please try again.