This repository has been archived by the owner on Mar 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7bfe957
Showing
19 changed files
with
1,285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.tgz | ||
*.phar | ||
composer.lock | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
default: | ||
extensions: | ||
Behat\MinkExtension\Extension: | ||
base_url: http://en.wikipedia.org/ | ||
goutte: ~ | ||
sahi: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "behat/mink-extension", | ||
"type": "behat-extension", | ||
"description": "Mink extension for Behat", | ||
"keywords": ["web", "test", "browser", "gui"], | ||
"homepage": "http://mink.behat.org", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Konstantin Kudryashov", | ||
"email": "ever.zet@gmail.com" | ||
} | ||
], | ||
|
||
"require": { | ||
"php": ">=5.3.2", | ||
"behat/behat": "dev-develop", | ||
"behat/mink": "1.4.0.x-dev" | ||
}, | ||
|
||
"require-dev": { | ||
"fabpot/goutte": "*", | ||
"behat/sahi-client": "*" | ||
}, | ||
|
||
"autoload": { | ||
"psr-0": { "Behat\\MinkExtension": "src/" } | ||
}, | ||
|
||
"repositories": { | ||
"behat/mink-deps": { | ||
"type": "composer", | ||
"url": "behat.org" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
use Behat\MinkExtension\Context\MinkContext; | ||
|
||
class FeatureContext extends MinkContext | ||
{ | ||
/** | ||
* @Then /^I wait for the suggestion box to appear$/ | ||
*/ | ||
public function iWaitForTheSuggestionBoxToAppear() | ||
{ | ||
$this->getSession()->wait(5000, "$('.suggestions-results').children().length > 0"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Feature: Search | ||
In order to see a word definition | ||
As a website user | ||
I need to be able to search for a word | ||
|
||
Scenario: Searching for a page that does exist | ||
Given I am on "/wiki/Main_Page" | ||
When I fill in "search" with "Behavior Driven Development" | ||
And I press "searchButton" | ||
Then I should see "agile software development" | ||
|
||
Scenario: Searching for a page that does NOT exist | ||
Given I am on "/wiki/Main_Page" | ||
When I fill in "search" with "Glory Driven Development" | ||
And I press "searchButton" | ||
Then I should see "Search results" | ||
|
||
@javascript | ||
Scenario: Searching for a page with autocompletion | ||
Given I am on "/wiki/Main_Page" | ||
When I fill in "search" with "Behavior Driv" | ||
And I wait for the suggestion box to appear | ||
Then I should see "Behavior Driven Development" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Behat\MinkExtension\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Reference, | ||
Symfony\Component\DependencyInjection\ContainerBuilder, | ||
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
|
||
/* | ||
* This file is part of the Behat\MinkExtension | ||
* | ||
* (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
/** | ||
* Selectors handler compilation pass. Registers all avaiable Mink selector engines. | ||
* | ||
* @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
*/ | ||
class SelectorsPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* Registers additional Mink selector handlers. | ||
* | ||
* @param ContainerBuilder $container | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('behat.mink.selectors_handler')) { | ||
return; | ||
} | ||
|
||
$handlerDefinition = $container->getDefinition('behat.mink.selectors_handler'); | ||
foreach ($container->findTaggedServiceIds('behat.mink.selector') as $id => $attributes) { | ||
foreach ($attributes as $attribute) { | ||
if (isset($attribute['alias']) && $alias = $attribute['alias']) { | ||
$handlerDefinition->addMethodCall( | ||
'registerSelector', array($alias, new Reference($id)) | ||
); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Behat\MinkExtension\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Reference, | ||
Symfony\Component\DependencyInjection\ContainerBuilder, | ||
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
|
||
/* | ||
* This file is part of the Behat\MinkExtension | ||
* | ||
* (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
/** | ||
* Behat\Mink container compilation pass. | ||
* Registers all available in controller Mink sessions. | ||
* | ||
* @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
*/ | ||
class SessionsPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* Registers Mink sessions. | ||
* | ||
* @param ContainerBuilder $container | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('behat.mink')) { | ||
return; | ||
} | ||
$minkDefinition = $container->getDefinition('behat.mink'); | ||
|
||
foreach ($container->findTaggedServiceIds('behat.mink.session') as $id => $attributes) { | ||
foreach ($attributes as $attribute) { | ||
if (isset($attribute['alias']) && $name = $attribute['alias']) { | ||
$minkDefinition->addMethodCall( | ||
'registerSession', array($name, new Reference($id)) | ||
); | ||
} | ||
} | ||
} | ||
|
||
$minkDefinition->addMethodCall( | ||
'setDefaultSessionName', array($container->getParameter('behat.mink.default_session')) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php | ||
|
||
namespace Behat\MinkExtension; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder, | ||
Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/* | ||
* This file is part of the Behat\MinkExtension | ||
* | ||
* (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
/** | ||
* MinkExtension configuration tree. | ||
* | ||
* @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* Returns configuration tree. | ||
* | ||
* @return TreeBuilder | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
|
||
return $treeBuilder->root('mink')-> | ||
children()-> | ||
scalarNode('base_url')-> | ||
defaultNull()-> | ||
end()-> | ||
scalarNode('files_path')-> | ||
defaultNull()-> | ||
end()-> | ||
scalarNode('show_cmd')-> | ||
defaultNull()-> | ||
end()-> | ||
scalarNode('show_tmp_dir')-> | ||
defaultValue(sys_get_temp_dir())-> | ||
end()-> | ||
scalarNode('default_session')-> | ||
defaultValue('goutte')-> | ||
end()-> | ||
scalarNode('javascript_session')-> | ||
defaultValue('sahi')-> | ||
end()-> | ||
scalarNode('browser_name')-> | ||
defaultValue('firefox')-> | ||
end()-> | ||
arrayNode('goutte')-> | ||
children()-> | ||
arrayNode('zend_config')-> | ||
useAttributeAsKey('key')-> | ||
prototype('variable')->end()-> | ||
end()-> | ||
arrayNode('server_parameters')-> | ||
useAttributeAsKey('key')-> | ||
prototype('variable')->end()-> | ||
end()-> | ||
end()-> | ||
end()-> | ||
arrayNode('sahi')-> | ||
children()-> | ||
scalarNode('sid')-> | ||
defaultNull()-> | ||
end()-> | ||
scalarNode('host')-> | ||
defaultValue('localhost')-> | ||
end()-> | ||
scalarNode('port')-> | ||
defaultValue(9999)-> | ||
end()-> | ||
end()-> | ||
end()-> | ||
arrayNode('zombie')-> | ||
children()-> | ||
scalarNode('host')-> | ||
defaultValue('127.0.0.1')-> | ||
end()-> | ||
scalarNode('port')-> | ||
defaultValue(8124)-> | ||
end()-> | ||
scalarNode('auto_server')-> | ||
defaultValue(true)-> | ||
end()-> | ||
scalarNode('node_bin')-> | ||
defaultValue('node')-> | ||
end()-> | ||
end()-> | ||
end()-> | ||
arrayNode('selenium')-> | ||
children()-> | ||
scalarNode('host')-> | ||
defaultValue('127.0.0.1')-> | ||
end()-> | ||
scalarNode('port')-> | ||
defaultValue(4444)-> | ||
end()-> | ||
scalarNode('browser')-> | ||
defaultValue('*%behat.mink.browser_name%')-> | ||
end()-> | ||
end()-> | ||
end()-> | ||
arrayNode('selenium2')-> | ||
children()-> | ||
scalarNode('browser')-> | ||
defaultValue('%behat.mink.browser_name%')-> | ||
end()-> | ||
arrayNode('capabilities')-> | ||
children()-> | ||
scalarNode('browserName')-> | ||
defaultValue('firefox')-> | ||
end()-> | ||
scalarNode('version')-> | ||
defaultValue(8)-> | ||
end()-> | ||
scalarNode('platform')-> | ||
defaultValue('ANY')-> | ||
end()-> | ||
scalarNode('browserVersion')-> | ||
defaultValue(8)-> | ||
end()-> | ||
scalarNode('browser')-> | ||
defaultValue('firefox')-> | ||
end()-> | ||
end()-> | ||
end()-> | ||
scalarNode('wd_host')-> | ||
defaultValue('http://localhost:4444/wd/hub')-> | ||
end()-> | ||
end()-> | ||
end()-> | ||
end()-> | ||
end(); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/Behat/MinkExtension/Context/MinkAwareContextInitializer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Behat\MinkExtension\Context; | ||
|
||
use Behat\Behat\Context\ContextInitializerInterface, | ||
Behat\Behat\Context\ContextInterface; | ||
|
||
use Behat\Mink\Mink; | ||
|
||
/* | ||
* This file is part of the Behat\MinkExtension. | ||
* (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* Mink aware contexts initializer. | ||
* Sets Mink instance and parameters to the MinkAware contexts. | ||
* | ||
* @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
*/ | ||
class MinkAwareContextInitializer implements ContextInitializerInterface | ||
{ | ||
private $mink; | ||
private $parameters; | ||
|
||
/** | ||
* Initializes initializer. | ||
* | ||
* @param Mink $mink | ||
* @param array $parameters | ||
*/ | ||
public function __construct(Mink $mink, array $parameters) | ||
{ | ||
$this->mink = $mink; | ||
$this->parameters = $parameters; | ||
} | ||
|
||
/** | ||
* Checks if initializer supports provided context. | ||
* | ||
* @param ContextInterface $context | ||
* | ||
* @return Boolean | ||
*/ | ||
public function supports(ContextInterface $context) | ||
{ | ||
return $context instanceof MinkAwareContextInterface; | ||
} | ||
|
||
/** | ||
* Initializes provided context. | ||
* | ||
* @param ContextInterface $context | ||
*/ | ||
public function initialize(ContextInterface $context) | ||
{ | ||
$context->setMink($this->mink); | ||
$context->setMinkParameters($this->parameters); | ||
} | ||
} |
Oops, something went wrong.