Permalink
Browse files

Merge branch 'release/1.2.0'

  • Loading branch information...
2 parents d0c2d91 + 5b919f5 commit 904514e627913e05f012803af540d9d55830d417 @everzet everzet committed Nov 4, 2011
Showing with 1,384 additions and 114 deletions.
  1. +3 −0 .gitmodules
  2. +11 −0 CHANGES.md
  3. +1 −0 autoload.php.dist
  4. +3 −2 behat.yml
  5. +48 −1 src/Behat/Mink/Behat/Context/BaseMinkContext.php
  6. +38 −20 src/Behat/Mink/Behat/Context/MinkContext.php
  7. +131 −0 src/Behat/Mink/Behat/Context/translations/de.xliff
  8. +58 −6 src/Behat/Mink/Behat/Context/translations/es.xliff
  9. +12 −0 src/Behat/Mink/Behat/Context/translations/ru.xliff
  10. +131 −0 src/Behat/Mink/Behat/Context/translations/sv.xliff
  11. +19 −0 src/Behat/Mink/Compiler/MapFileCompiler.php
  12. +12 −1 src/Behat/Mink/Compiler/PearCompiler.php
  13. +8 −1 src/Behat/Mink/Compiler/PharCompiler.php
  14. +2 −1 src/Behat/Mink/Driver/DriverInterface.php
  15. +20 −4 src/Behat/Mink/Driver/GoutteDriver.php
  16. +6 −6 src/Behat/Mink/Driver/SahiDriver.php
  17. +636 −0 src/Behat/Mink/Driver/SeleniumDriver.php
  18. +4 −6 src/Behat/Mink/Driver/Zombie/Server.php
  19. +4 −13 src/Behat/Mink/Driver/ZombieDriver.php
  20. +23 −3 src/Behat/Mink/Element/NodeElement.php
  21. +25 −0 src/Behat/Mink/PHPUnit/TestCase.php
  22. +1 −1 src/Behat/Mink/Selector/NamedSelector.php
  23. +77 −31 tests/Behat/Mink/Driver/GeneralDriverTest.php
  24. +2 −2 tests/Behat/Mink/Driver/JavascriptDriverTest.php
  25. +33 −0 tests/Behat/Mink/Driver/SeleniumDriverTest.php
  26. +10 −0 tests/Behat/Mink/Driver/ZombieDriverTest.php
  27. +6 −0 tests/Behat/Mink/Driver/web-fixtures/advanced_form.php
  28. +5 −1 tests/Behat/Mink/Driver/web-fixtures/advanced_form_post.php
  29. +10 −3 tests/Behat/Mink/Driver/web-fixtures/headers.php
  30. +15 −2 tests/Behat/Mink/Driver/web-fixtures/index.php
  31. +10 −2 tests/Behat/Mink/Driver/web-fixtures/print_cookies.php
  32. +12 −1 tests/Behat/Mink/Driver/web-fixtures/redirect_destination.php
  33. +1 −1 vendor/Buzz
  34. +1 −1 vendor/Goutte
  35. +1 −1 vendor/Symfony/Component/BrowserKit
  36. +1 −1 vendor/Symfony/Component/CssSelector
  37. +1 −1 vendor/Symfony/Component/DomCrawler
  38. +1 −1 vendor/Symfony/Component/Finder
  39. +1 −1 vendor/Symfony/Component/Process
  40. +1 −0 vendor/php-selenium
View
@@ -22,3 +22,6 @@
[submodule "vendor/Symfony/Component/DomCrawler"]
path = vendor/Symfony/Component/DomCrawler
url = git://github.com/symfony/DomCrawler.git
+[submodule "vendor/php-selenium"]
+ path = vendor/php-selenium
+ url = https://github.com/alexandresalome/PHP-Selenium
View
@@ -1,3 +1,14 @@
+1.2.0 / 2011-11-04
+==================
+
+ * Brand new SeleniumDriver (thanks @alexandresalome)
+ * Multiselect support (multiple options selection), including new Behat steps
+ * Ability to select option by it's text (in addition to value)
+ * ZombieDriver updates
+ * Use SuiteHooks to populate parameters (no need to call parent __construct anymore)
+ * Updated Goutte and all vendors
+ * Lot of bugfixes and new tests
+
1.1.1 / 2011-08-12
==================
View
@@ -21,5 +21,6 @@ $loader->registerNamespaces(array(
'Buzz' => __DIR__ . '/vendor/Buzz/lib',
'Goutte' => __DIR__ . '/vendor/Goutte/src',
'Zend' => __DIR__ . '/vendor/Goutte/vendor/zend/library',
+ 'Selenium' => __DIR__ . '/vendor/php-selenium/src',
));
$loader->register();
View
@@ -1,5 +1,6 @@
default:
context:
parameters:
- base_url: http://test.mink.dev/
- show_cmd: open %s
+ javascript_session: selenium
+ base_url: http://test.mink.dev/
+ show_cmd: open %s
@@ -209,6 +209,18 @@ public function selectOption($select, $option)
}
/**
+ * Selects additional option in select field with specified id|name|label|value.
+ *
+ * @When /^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
+ */
+ public function additionallySelectOption($select, $option)
+ {
+ $select = str_replace('\\"', '"', $select);
+ $option = str_replace('\\"', '"', $option);
+ $this->getSession()->getPage()->selectFieldOption($select, $option, true);
+ }
+
+ /**
* Checks checkbox with specified id|name|label|value.
*
* @When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
@@ -304,6 +316,23 @@ public function assertResponseStatus($code)
}
/**
+ * Checks, that current page response status is not equal to specified.
+ *
+ * @Then /^the response status code should not be (?P<code>\d+)$/
+ */
+ public function assertResponseStatusIsNot($code)
+ {
+ $actual = $this->getSession()->getStatusCode();
+
+ try {
+ assertNotEquals($actual, $code);
+ } catch (AssertException $e) {
+ $message = sprintf('Current response status code is %d, but should not be', $actual);
+ throw new ExpectationException($message, $this->getSession(), $e);
+ }
+ }
+
+ /**
* Checks, that page contains specified text.
*
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
@@ -553,6 +582,22 @@ public function assertCheckboxNotChecked($checkbox)
}
/**
+ * Checks, that (?P<num>\d+) CSS elements exist on the page
+ *
+ * @Then /^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/
+ */
+ public function assertNumElements($num, $element)
+ {
+ $nodes = $world->getSession()->getPage()->findAll('css', $element);
+
+ if (null === $nodes) {
+ throw new ElementNotFoundException($world->getSession(), 'element: '.$element.' ');
+ }
+
+ assertSame((int) $num, count($nodes));
+ }
+
+ /**
* Prints last response to console.
*
* @Then /^print last response$/
@@ -578,7 +623,7 @@ public function showLastResponse()
$filename = rtrim($this->getParameter('show_tmp_dir'), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.uniqid().'.html';
file_put_contents($filename, $this->getSession()->getPage()->getContent());
- system(sprintf($this->getParameter('show_cmd'), $filename));
+ system(sprintf($this->getParameter('show_cmd'), escapeshellarg($filename)));
}
/**
@@ -595,6 +640,8 @@ public function getTranslationResources()
__DIR__ . '/translations/es.xliff',
__DIR__ . '/translations/nl.xliff',
__DIR__ . '/translations/pt.xliff',
+ __DIR__ . '/translations/sv.xliff',
+ __DIR__ . '/translations/de.xliff',
);
}
}
@@ -8,7 +8,8 @@
Behat\Mink\Session,
Behat\Mink\Driver\GoutteDriver,
Behat\Mink\Driver\SahiDriver,
- Behat\Mink\Driver\ZombieDriver;
+ Behat\Mink\Driver\ZombieDriver,
+ Behat\Mink\Driver\SeleniumDriver;
use Goutte\Client as GoutteClient;
@@ -18,6 +19,8 @@
use Behat\Mink\Driver\Zombie\Connection as ZombieConnection,
Behat\Mink\Driver\Zombie\Server as ZombieServer;
+use Selenium\Client as SeleniumClient;
+
/*
* This file is part of the Behat\Mink.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
@@ -34,19 +37,7 @@
class MinkContext extends BaseMinkContext
{
private static $mink;
- private $parameters;
-
- /**
- * Initializes Mink environment.
- *
- * @param array $parameters list of context parameters
- */
- public function __construct(array $parameters = array())
- {
- $this->parameters = static::mergeConfigWithDefaults(
- static::getDefaultParameters(), $parameters
- );
- }
+ private static $parameters;
/**
* {@inheritdoc}
@@ -67,19 +58,19 @@ public function getMink()
*/
public function getParameters()
{
- return $this->parameters;
+ return self::$parameters;
}
/**
* {@inheritdoc}
*/
public function getParameter($name)
{
- if (!isset($this->parameters[$name])) {
+ if (!isset(self::$parameters[$name])) {
return;
}
- return $this->parameters[$name];
+ return self::$parameters[$name];
}
/**
@@ -91,15 +82,15 @@ public function getParameter($name)
*/
public static function initMinkSessions(SuiteEvent $event)
{
- $parameters = static::mergeConfigWithDefaults(
+ self::$parameters = static::mergeConfigWithDefaults(
static::getDefaultParameters(), $event->getContextParameters()
);
if (null === self::$mink) {
self::$mink = new Mink();
}
- static::registerMinkSessions(self::$mink, $parameters);
+ static::registerMinkSessions(self::$mink, self::$parameters);
}
/**
@@ -140,6 +131,13 @@ protected static function registerMinkSessions(Mink $mink, array $parameters)
$params['host'], $params['port'], $params['auto_server'], $params['node_bin']
));
}
+
+ if (!$mink->hasSession('selenium')) {
+ $params = $parameters['selenium'];
+ $mink->registerSession('selenium', static::initSeleniumSession(
+ $parameters['browser'], $parameters['base_url'], $params['host'], $params['port']
+ ));
+ }
}
/**
@@ -152,6 +150,8 @@ protected static function registerMinkSessions(Mink $mink, array $parameters)
*/
protected static function initGoutteSession(array $zendConfig = array(), array $serverParameters = array())
{
+ $zendConfig = array_merge(array('encodecookies' => false), $zendConfig);
+
return new Session(new GoutteDriver(new GoutteClient($zendConfig, $serverParameters)));
}
@@ -190,6 +190,20 @@ protected static function initZombieSession($host = '127.0.0.1', $port = 8124,
}
/**
+ * Initizalizes and returns new SeleniumDriver session.
+ *
+ * @param string $browser browser name to use (default = firefox)
+ * @param string $host sahi proxy host
+ * @param integer $port port number
+ *
+ * @return Behat\Mink\Session
+ */
+ protected static function initSeleniumSession($browser, $baseUrl, $host, $port)
+ {
+ return new Session(new SeleniumDriver($browser, $baseUrl, new SeleniumClient($host, $port)));
+ }
+
+ /**
* Returns list of default parameters.
*
* @return array
@@ -217,7 +231,11 @@ protected static function getDefaultParameters()
'port' => 8124,
'node_bin' => 'node',
'auto_server' => true
- )
+ ),
+ 'selenium' => array(
+ 'host' => 'localhost',
+ 'port' => 4444
+ ),
);
}
@@ -0,0 +1,131 @@
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file original="global" source-language="en" target-language="de" datatype="plaintext">
+ <header />
+ <body>
+ <trans-unit id="i-am-on-page">
+ <source><![CDATA[/^(?:|I )am on "(?P<page>[^"]+)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )bin auf "(?P<page>[^"]+)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-go-to-page">
+ <source><![CDATA[/^(?:|I )go to "(?P<page>[^"]+)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )gehe nach "(?P<page>[^"]+)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="reload-the-page">
+ <source><![CDATA[/^(?:|I )reload the page$/]]></source>
+ <target><![CDATA[/^(?:|ich )aktualisiere die Seite$/]]></target>
+ </trans-unit>
+ <trans-unit id="move-backward-one-page">
+ <source><![CDATA[/^(?:|I )move backward one page$/]]></source>
+ <target><![CDATA[/^(?:|ich )gehe eine Seite zurück$/]]></target>
+ </trans-unit>
+ <trans-unit id="move-forward-one-page">
+ <source><![CDATA[/^(?:|I )move forward one page$/]]></source>
+ <target><![CDATA[/^(?:|ich )gehe eine Seite vorwärts$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-press-button">
+ <source><![CDATA[/^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )drücke "(?P<button>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-follow-link">
+ <source><![CDATA[/^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )folge "(?P<link>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-fill-in-field-with-value">
+ <source><![CDATA[/^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )gebe in das Feld "(?P<field>(?:[^"]|\\")*)" "(?P<value>(?:[^"]|\\")*)" ein$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-fill-in-value-for-field">
+ <source><![CDATA[/^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )gebe "(?P<value>(?:[^"]|\\")*)" in "(?P<field>(?:[^"]|\\")*)"ein$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-fill-in-the-following">
+ <source><![CDATA[/^(?:|I )fill in the following:$/]]></source>
+ <target><![CDATA[/^(?:|ich )gebe das folgende ein:$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-select-option-from-select">
+ <source><![CDATA[/^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )wähle "(?P<option>(?:[^"]|\\")*)" von "(?P<select>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-check-option">
+ <source><![CDATA[/^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )aktiviere "(?P<option>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-uncheck-option">
+ <source><![CDATA[/^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )deaktiviere "(?P<option>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-attach-the-file-to-field">
+ <source><![CDATA[/^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )lade die Datei "(?P<path>[^"]*)" in "(?P<field>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-see-text">
+ <source><![CDATA[/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )sollte "(?P<text>(?:[^"]|\\")*)" sehen$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-response-should-contain">
+ <source><![CDATA[/^the response should contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^die Rückmeldung sollte "(?P<text>(?:[^"]|\\")*)" enthalten$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-not-see-text">
+ <source><![CDATA[/^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )sollte nicht "(?P<text>(?:[^"]|\\")*)" sehen$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-response-should-not-contain">
+ <source><![CDATA[/^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^die Rückmeldung sollte nicht "(?P<text>(?:[^"]|\\")*)" enthalten$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-field-should-contain-value">
+ <source><![CDATA[/^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^das "(?P<field>(?:[^"]|\\")*)" Feld sollte "(?P<value>(?:[^"]|\\")*)" enthalten$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-field-should-not-contain-value">
+ <source><![CDATA[/^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^das "(?P<field>(?:[^"]|\\")*)" Feld sollte nicht "(?P<value>(?:[^"]|\\")*)" enthalten$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-checkbox-should-be-checked">
+ <source><![CDATA[/^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/]]></source>
+ <target><![CDATA[/^die "(?P<checkbox>(?:[^"]|\\")*)" checkbox sollte aktiviert sein$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-checkbox-should-not-be-checked">
+ <source><![CDATA[/^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should not be checked$/]]></source>
+ <target><![CDATA[/^die "(?P<checkbox>(?:[^"]|\\")*)" checkbox sollte nicht aktiviert sein$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-be-on-page">
+ <source><![CDATA[/^(?:|I )should be on "(?P<page>[^"]+)"$/]]></source>
+ <target><![CDATA[/^(?:|ich )sollte auf "(?P<page>[^"]+) sein"$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-url-should-match">
+ <source><![CDATA[/^the url should match "(?P<pattern>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^die Webadresse sollte mit "(?P<pattern>(?:[^"]|\\")*)" übereinstimmen$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-element-should-contain">
+ <source><![CDATA[/^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^das "(?P<element>[^"]*)" Element sollte "(?P<value>(?:[^"]|\\")*)" enthalten$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-see-text-in-element">
+ <source><![CDATA[/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/]]></source>
+ <target><![CDATA[/^(?:|ich )sollte "(?P<text>(?:[^"]|\\")*)" im "(?P<element>[^"]*)" Element sehen$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-see-element">
+ <source><![CDATA[/^(?:|I )should see an? "(?P<element>[^"]*)" element$/]]></source>
+ <target><![CDATA[/^(?:|ich )sollte ein "(?P<element>[^"]*)" Element sehen$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-not-see-element">
+ <source><![CDATA[/^(?:|I )should not see an? "(?P<element>[^"]*)" element$/]]></source>
+ <target><![CDATA[/^(?:|ich )sollte kein "(?P<element>[^"]*)" Element sehen$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-response-status-code-should-be">
+ <source><![CDATA[/^the response status code should be (?P<code>\d+)$/]]></source>
+ <target><![CDATA[/^die Status-Code-Rückmeldung sollte (?P<code>\d+) sein$/]]></target>
+ </trans-unit>
+ <trans-unit id="print-last-response">
+ <source><![CDATA[/^print last response$/]]></source>
+ <target><![CDATA[/^gib die letzte Rückmeldung aus$/]]></target>
+ </trans-unit>
+ <trans-unit id="show-last-response">
+ <source><![CDATA[/^show last response$/]]></source>
+ <target><![CDATA[/^zeige die letzte Rückmeldung$/]]></target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
Oops, something went wrong.

0 comments on commit 904514e

Please sign in to comment.