Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/zombor/Mink into zombor-m…
Browse files Browse the repository at this point in the history
…aster
  • Loading branch information
everzet committed Apr 21, 2011
2 parents cd1cddb + b41c7ea commit 88d5eaf
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/Behat/Mink/Integration/steps/mink_steps.php
Expand Up @@ -18,6 +18,11 @@
$world->getSession()->visit($world->getPathTo($page));
});

$steps->When('/^(?:|I ) successfully go to (?P<page>.+)$/', function($world, $page) use($steps) {
$world->getSession()->visit($world->getPathTo($page));
$steps->Then('the status code should be 200');
});

$steps->When('/^(?:|I )press "(?P<button>[^"]*)"$/', function($world, $button) {
$world->getSession()->getPage()->clickButton($button);
});
Expand Down Expand Up @@ -111,3 +116,56 @@
parse_url($world->getSession()->getCurrentUrl(), PHP_URL_PATH)
);
});

$steps->Then('/^the (?P<element>[^"].*) element should contain "(?P<value>[^"]*)"$/', function($world, $element, $value)
{
$node = $world->getSession()->getPage()->find('xpath', $element);

if (null === $node) {
throw new ElementNotFoundException('element', $element);
}

assertContains($value, preg_replace('/\s+/', ' ', str_replace("\n", '', $node->getText())));
});

$steps->Then('/^the (?P<element>[^"].*) element should exist$/', function($world, $element)
{
$node = $world->getSession()->getPage()->find('xpath', $element);

if (null === $node) {
throw new ElementNotFoundException('element', $element);
}
});

$steps->Then('/^the (?P<element>[^"].*) element should link to (?P<href>[^"].*)$/', function($world, $element, $href)
{
$node = $world->getSession()->getPage()->find('xpath', $element);

if (null === $node) {
throw new ElementNotFoundException('element', $element);
}

$href_parts = parse_url($href);
$href = array_merge(
parse_url($world->getParameter('start_url')),
$href_parts
);

assertSame($href['scheme'].'://'.$href['host'].$href['path'], $node->getAttribute('href'));
});

$steps->Then('/^the (?P<element>[^"].*) element should have a (?P<attribute>[^"].*) attribute of (?P<value>[^"].*)$/', function($world, $element, $attribute, $value)
{
$node = $world->getSession()->getPage()->find('xpath', $element);

if (null === $node) {
throw new ElementNotFoundException('element', $element);
}

assertSame($value, $node->getAttribute($attribute));
});

$steps->Then('/the status code should be (?P<status_code>\d+)/', function($world, $status_code)
{
assertSame($world->getSession()->getStatusCode(), (int) $status_code);
})

0 comments on commit 88d5eaf

Please sign in to comment.