Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/1.3.0'

  • Loading branch information...
commit 164b2f6e3d4396d1d2b6c22316eb6716d56d6231 2 parents 5ece94b + 0a1fffe
@everzet everzet authored
Showing with 1,967 additions and 765 deletions.
  1. +2 −0  .gitignore
  2. +0 −27 .gitmodules
  3. +15 −0 .travis.yml
  4. +10 −0 CHANGES.md
  5. +50 −0 README.md
  6. +0 −26 autoload.php.dist
  7. +7 −0 bin/install_deps
  8. +8 −0 bin/install_sahi
  9. +16 −0 bin/install_selenium
  10. +3 −0  bin/kill_sahi
  11. +3 −0  bin/kill_selenium
  12. +4 −1 bin/release
  13. +11 −0 bin/run_all_tests
  14. +7 −0 bin/start_sahi
  15. +7 −0 bin/start_selenium
  16. +197 −0 composer.json
  17. +1 −5 features/bootstrap/FeatureContext.php
  18. +1 −1  phpunit.xml.dist
  19. +3 −3 src/Behat/Mink/Behat/Context/BaseMinkContext.php
  20. +37 −7 src/Behat/Mink/Behat/Context/MinkContext.php
  21. +39 −27 src/Behat/Mink/Behat/Context/translations/es.xliff
  22. +62 −18 src/Behat/Mink/Behat/Context/translations/fr.xliff
  23. +0 −261 src/Behat/Mink/ClassLoader/UniversalClassLoader.php
  24. +10 −88 src/Behat/Mink/Compiler/MapFileCompiler.php
  25. +44 −53 src/Behat/Mink/Compiler/PearCompiler.php
  26. +49 −71 src/Behat/Mink/Compiler/PharCompiler.php
  27. +96 −71 src/Behat/Mink/Driver/GoutteDriver.php
  28. +55 −27 src/Behat/Mink/Driver/SahiDriver.php
  29. +67 −0 src/Behat/Mink/Driver/Selenium2/syn.js
  30. +832 −0 src/Behat/Mink/Driver/Selenium2Driver.php
  31. +25 −10 src/Behat/Mink/Driver/SeleniumDriver.php
  32. +12 −10 src/Behat/Mink/Driver/Zombie/Server.php
  33. +20 −7 src/Behat/Mink/Driver/ZombieDriver.php
  34. +2 −2 src/Behat/Mink/Element/TraversableElement.php
  35. +25 −5 src/Behat/Mink/PHPUnit/TestCase.php
  36. +1 −1  src/Behat/Mink/Session.php
  37. +77 −13 tests/Behat/Mink/Driver/GeneralDriverTest.php
  38. +13 −0 tests/Behat/Mink/Driver/JavascriptDriverTest.php
  39. +11 −0 tests/Behat/Mink/Driver/SahiDriverTest.php
  40. +36 −0 tests/Behat/Mink/Driver/Selenium2DriverTest.php
  41. +11 −0 tests/Behat/Mink/Driver/SeleniumDriverTest.php
  42. +5 −0 tests/Behat/Mink/Driver/ZombieDriverTest.php
  43. +2 −7 tests/Behat/Mink/Driver/web-fixtures/advanced_form.php
  44. +17 −0 tests/Behat/Mink/Driver/web-fixtures/issue131.php
  45. 0  tests/Behat/Mink/Driver/web-fixtures/js/jquery-ui-1.8.14.custom.min.js
  46. +24 −0 tests/Behat/Mink/Driver/web-fixtures/js_test.php
  47. +26 −0 tests/Behat/Mink/Driver/web-fixtures/multiselect_form.php
  48. +3 −0  tests/Behat/Mink/Element/DocumentElementTest.php
  49. +3 −0  tests/Behat/Mink/Element/ElementTest.php
  50. +3 −0  tests/Behat/Mink/Element/NodeElementTest.php
  51. +3 −0  tests/Behat/Mink/MinkTest.php
  52. +3 −0  tests/Behat/Mink/Selector/CssSelectorTest.php
  53. +3 −0  tests/Behat/Mink/Selector/NamedSelectorTest.php
  54. +3 −0  tests/Behat/Mink/Selector/SelectorsHandlerTest.php
  55. +3 −0  tests/Behat/Mink/SessionTest.php
  56. +0 −15 tests/bootstrap.php
  57. +0 −1  vendor/Buzz
  58. +0 −1  vendor/Goutte
  59. +0 −1  vendor/SahiClient
  60. +0 −1  vendor/Symfony/Component/BrowserKit
  61. +0 −1  vendor/Symfony/Component/CssSelector
  62. +0 −1  vendor/Symfony/Component/DomCrawler
  63. +0 −1  vendor/Symfony/Component/Finder
  64. +0 −1  vendor/Symfony/Component/Process
  65. +0 −1  vendor/php-selenium
View
2  .gitignore
@@ -1,3 +1,5 @@
*.tgz
*.phar
phpunit.xml
+composer.lock
+vendor
View
27 .gitmodules
@@ -1,27 +0,0 @@
-[submodule "vendor/Goutte"]
- path = vendor/Goutte
- url = git://github.com/fabpot/Goutte.git
-[submodule "vendor/Symfony/Component/CssSelector"]
- path = vendor/Symfony/Component/CssSelector
- url = git://github.com/symfony/CssSelector.git
-[submodule "vendor/SahiClient"]
- path = vendor/SahiClient
- url = git://github.com/Behat/SahiClient.git
-[submodule "vendor/Buzz"]
- path = vendor/Buzz
- url = git://github.com/kriswallsmith/Buzz.git
-[submodule "vendor/Symfony/Component/Finder"]
- path = vendor/Symfony/Component/Finder
- url = git://github.com/symfony/Finder
-[submodule "vendor/Symfony/Component/BrowserKit"]
- path = vendor/Symfony/Component/BrowserKit
- url = git://github.com/symfony/BrowserKit.git
-[submodule "vendor/Symfony/Component/Process"]
- path = vendor/Symfony/Component/Process
- url = git://github.com/symfony/Process.git
-[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
15 .travis.yml
@@ -0,0 +1,15 @@
+language: php
+
+php:
+ - 5.3
+ - 5.4
+
+branches:
+ only:
+ - master
+ - develop
+
+before_script:
+ - bin/install_deps
+
+script: phpunit --group unittest
View
10 CHANGES.md
@@ -1,3 +1,13 @@
+1.3.0 / 2011-12-21
+==================
+
+ * Brand new Selenium2Driver (webdriver session)
+ * Multiselect bugfixes
+ * ZombieDriver back in the business
+ * Composer now manages dependencies
+ * Some MinkContext steps got fixes
+ * Lots of bug fixes and cleanup
+
1.2.0 / 2011-11-04
==================
View
50 README.md
@@ -1,6 +1,8 @@
Mink
====
+[![Build Status](https://secure.travis-ci.org/Behat/Mink.png)](http://travis-ci.org/Behat/Mink)
+
* The main website with documentation is at
[http://mink.behat.org](http://mink.behat.org)
* Official user group is at [Google Groups](http://groups.google.com/group/behat)
@@ -46,6 +48,52 @@ $mink->getSession('goutte1')->getPage()->findLink('Chat')->click();
$mink->getSession('goutte2')->getPage()->findLink('Chat')->click();
```
+Install Dependencies
+--------------------
+
+ wget http://getcomposer.org/composer.phar
+ php composer.phar install
+
+How to run Mink test suite
+--------------------------
+
+1. Install dependencies (including Sahi and Selenium)
+
+ ``` bash
+ bin/install_deps
+ bin/install_sahi
+ bin/install_selenium
+ ```
+
+2. To run all tests - call `bin/run_all_tests`
+
+If you want to run specific driver tests, use appropriate PHPUnit group
+and make sure that `Sahi`/`Selenium` is runned if you want to test
+one of them:
+
+``` bash
+bin/start_sahi
+phpunit --group sahidriver
+bin/kill_sahi
+```
+
+``` bash
+bin/start_selenium
+phpunit --group seleniumdriver
+bin/kill_selenium
+```
+
+`Zombie` and `Goutte` driver tests doesn't require some specific proxy
+to be runned and could be tested as is:
+
+``` bash
+phpunit --group zombiedriver
+```
+
+``` bash
+phpunit --group gouttedriver
+```
+
Translated languages
--------------------
@@ -72,6 +120,8 @@ Contributors
* Konstantin Kudryashov [everzet](http://github.com/everzet) [lead developer]
* Pascal Cremer [b00giZm](http://github.com/b00giZm) [ZombieDriver creator]
+* Alexandre Salomé [alexandresalome](http://github.com/alexandresalome) [SeleniumDriver creator]
+* Pete Otaqui [pete-otaqui](http://github.com/pete-otaqui) [Selenium2Driver creator]
Sponsors
--------
View
26 autoload.php.dist
@@ -1,26 +0,0 @@
-<?php
-
-/*
- * This file is part of the Behat\Mink.
- * (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.
- */
-
-if (!class_exists('Behat\Mink\ClassLoader\UniversalClassLoader')) {
- require_once __DIR__ . '/src/Behat/Mink/ClassLoader/UniversalClassLoader.php';
-}
-use Behat\Mink\ClassLoader\UniversalClassLoader;
-
-$loader = new UniversalClassLoader();
-$loader->registerNamespaces(array(
- 'Behat\Mink' => __DIR__ . '/src',
- 'Behat\SahiClient' => __DIR__ . '/vendor/SahiClient/src',
- 'Symfony\Component' => __DIR__ . '/vendor',
- '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
7 bin/install_deps
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+BASEDIR=$(dirname $0)
+cd $BASEDIR/..
+
+wget -nc http://getcomposer.org/composer.phar
+php composer.phar install
View
8 bin/install_sahi
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+BASEDIR=$(dirname $0)
+cd $BASEDIR/../vendor
+
+wget http://downloads.sourceforge.net/project/sahi/sahi-v35/20110719/sahi_20110719.zip -O sahi.zip
+unzip sahi.zip
+rm sahi.zip
View
16 bin/install_selenium
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+BASEDIR=$(dirname $0)
+cd $BASEDIR/../vendor
+
+wget http://selenium.googlecode.com/files/selenium-server-standalone-2.15.0.jar -O selenium.jar
+
+jar xf selenium.jar core/scripts/atoms.js
+ed -- "core/scripts/atoms.js" <<-PATCH
+ 9423s|a.|XPCNativeWrapper(a).|
+ w
+ q
+PATCH
+jar -uf selenium.jar core
+
+rm -r core
View
3  bin/kill_sahi
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ps -ef|grep sahi|grep -v grep|awk '{print $2}'|xargs kill -9
View
3  bin/kill_selenium
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ps -ef|grep selenium|grep -v grep|awk '{print $2}'|xargs kill -9
View
5 bin/release
@@ -17,10 +17,12 @@
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
-require_once __DIR__ . '/../autoload.php.dist';
+require_once __DIR__ . '/../vendor/.composer/autoload.php';
use Behat\Mink\Compiler;
+system('rm *.phar *.tgz');
+
if (!isset($argv[1])) {
throw new RuntimeException('You must provide version.');
}
@@ -41,6 +43,7 @@ echo "PEAR package compiled: mink-$version.tgz\n";
$phar = new Compiler\PharCompiler();
$phar->compile($version);
+system("cp mink-$version.phar mink.phar");
echo "PHAR package compiled: mink-$version.phar\n";
unlink($autoloaderFilename);
View
11 bin/run_all_tests
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+bin/kill_sahi
+bin/start_sahi
+bin/kill_selenium
+bin/start_selenium
+
+phpunit
+
+bin/kill_selenium
+bin/kill_sahi
View
7 bin/start_sahi
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+BASEDIR=$(dirname $0)
+cd $BASEDIR/../vendor/sahi/bin
+
+sh sahi.sh > /dev/null &
+sleep 5
View
7 bin/start_selenium
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+BASEDIR=$(dirname $0)
+cd $BASEDIR/../vendor
+
+java -jar selenium.jar > /dev/null &
+sleep 5
View
197 composer.json
@@ -0,0 +1,197 @@
+{
+ "name": "behat/mink",
+ "description": "Web acceptance testing framework for PHP 5.3",
+ "keywords": ["web", "testing", "browser"],
+ "homepage": "http://mink.behat.org/",
+ "type": "library",
+ "license": "MIT",
+
+ "authors": [
+ {
+ "name": "Konstantin Kudryashov",
+ "email": "ever.zet@gmail.com",
+ "homepage": "http://everzet.com"
+ }
+ ],
+
+ "require": {
+ "php": ">=5.3.1",
+ "symfony/browser-kit": ">=2.0",
+ "symfony/dom-crawler": ">=2.0",
+ "symfony/css-selector": ">=2.0",
+ "symfony/finder": ">=2.0",
+ "symfony/process": ">=2.0"
+ },
+
+ "recommend": {
+ "fabpot/goutte": "*",
+ "behat/sahi-client": ">=1.0.1",
+ "alexandresalome/php-selenium": "*",
+ "facebook/php-webdriver": "*"
+ },
+
+ "autoload": {
+ "psr-0": {
+ "Behat\\Mink": "src/"
+ }
+ },
+
+ "repositories": {
+ "fabpot/goutte": {
+ "package": {
+ "name": "fabpot/goutte",
+ "version": "master-dev",
+ "dist": {
+ "url": "https://github.com/fabpot/Goutte/zipball/master",
+ "type": "zip"
+ },
+ "source": {
+ "url": "git://github.com/fabpot/Goutte.git",
+ "type": "git",
+ "reference": "master"
+ },
+ "require": {
+ "symfony/browser-kit": ">=2.0",
+ "symfony/dom-crawler": ">=2.0",
+ "symfony/css-selector": ">=2.0",
+ "symfony/finder": ">=2.0",
+ "symfony/process": ">=2.0",
+ "zendframework/zend-registry": ">=2.0beta1,<3.0",
+ "zendframework/zend-loader": ">=2.0beta1,<3.0",
+ "zendframework/zend-stdlib": ">=2.0beta1,<3.0",
+ "zendframework/zend-validator": ">=2.0beta1,<3.0",
+ "zendframework/zend-http": ">=2.0beta1,<3.0",
+ "zendframework/zend-uri": ">=2.0beta1,<3.0"
+ },
+ "autoload": {
+ "psr-0": { "Goutte": "src/" }
+ }
+ }
+ },
+ "alexandresalome/php-selenium": {
+ "package": {
+ "name": "alexandresalome/php-selenium",
+ "version": "master-dev",
+ "dist": {
+ "url": "https://github.com/alexandresalome/PHP-Selenium/zipball/master",
+ "type": "zip"
+ },
+ "source": {
+ "url": "git://github.com/alexandresalome/PHP-Selenium.git",
+ "type": "git",
+ "reference": "master"
+ },
+ "require": {
+ "symfony/dom-crawler": ">=2.0"
+ },
+ "autoload": {
+ "psr-0": { "Selenium": "src/" }
+ }
+ }
+ },
+ "facebook/php-webdriver": {
+ "package": {
+ "name": "facebook/php-webdriver",
+ "version": "master-dev",
+ "dist": {
+ "url": "https://github.com/facebook/php-webdriver/zipball/master",
+ "type": "zip"
+ },
+ "source": {
+ "url": "git://github.com/facebook/php-webdriver.git",
+ "type": "git",
+ "reference": "master"
+ },
+ "autoload": {
+ "psr-0": {
+ "WebDriverBase": ".",
+ "WebDriver": ".",
+ "WebDriverContainer": ".",
+ "WebDriverSession": ".",
+ "WebDriverElement": ".",
+ "WebDriverEnvironment": ".",
+ "WebDriverSimpleItem": "."
+ }
+ }
+ }
+ },
+ "zendframework/zend-registry": {
+ "package": {
+ "name": "zendframework/zend-registry",
+ "version": "2.0.0beta1",
+ "dist": {
+ "url": "http://packages.zendframework.com/get/Zend_Registry-2.0.0beta1.tgz",
+ "type": "pear"
+ },
+ "autoload": {
+ "psr-0": { "Zend\\Registry": "php/" }
+ }
+ }
+ },
+ "zendframework/zend-loader": {
+ "package": {
+ "name": "zendframework/zend-loader",
+ "version": "2.0.0beta1",
+ "dist": {
+ "url": "http://packages.zendframework.com/get/Zend_Loader-2.0.0beta1.tgz",
+ "type": "pear"
+ },
+ "autoload": {
+ "psr-0": { "Zend\\Loader": "php/" }
+ }
+ }
+ },
+ "zendframework/zend-stdlib": {
+ "package": {
+ "name": "zendframework/zend-stdlib",
+ "version": "2.0.0beta1",
+ "dist": {
+ "url": "http://packages.zendframework.com/get/Zend_Stdlib-2.0.0beta1.tgz",
+ "type": "pear"
+ },
+ "autoload": {
+ "psr-0": { "Zend\\Stdlib": "php/" }
+ }
+ }
+ },
+ "zendframework/zend-validator": {
+ "package": {
+ "name": "zendframework/zend-validator",
+ "version": "2.0.0beta1",
+ "dist": {
+ "url": "http://packages.zendframework.com/get/Zend_Validator-2.0.0beta1.tgz",
+ "type": "pear"
+ },
+ "autoload": {
+ "psr-0": { "Zend\\Validator": "php/" }
+ }
+ }
+ },
+ "zendframework/zend-http": {
+ "package": {
+ "name": "zendframework/zend-http",
+ "version": "2.0.0beta1",
+ "dist": {
+ "url": "http://packages.zendframework.com/get/Zend_Http-2.0.0beta1.tgz",
+ "type": "pear"
+ },
+ "autoload": {
+ "psr-0": { "Zend\\Http": "php/" }
+ }
+ }
+ },
+ "zendframework/zend-uri": {
+ "package": {
+ "name": "zendframework/zend-uri",
+ "version": "2.0.0beta1",
+ "dist": {
+ "url": "http://packages.zendframework.com/get/Zend_Uri-2.0.0beta1.tgz",
+ "type": "pear"
+ },
+ "autoload": {
+ "psr-0": { "Zend\\Uri": "php/" }
+ }
+ }
+ }
+ }
+}
View
6 features/bootstrap/FeatureContext.php
@@ -8,11 +8,7 @@
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
-if (file_exists(__DIR__ . '/../../autoload.php')) {
- require_once __DIR__ . '/../../autoload.php';
-} else {
- require_once __DIR__ . '/../../autoload.php.dist';
-}
+require_once __DIR__.'/../../vendor/.composer/autoload.php';
/**
* Features context.
View
2  phpunit.xml.dist
@@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
- bootstrap="tests/bootstrap.php"
+ bootstrap="vendor/.composer/autoload.php"
>
<testsuites>
<testsuite name="Behat Mink test suite">
View
6 src/Behat/Mink/Behat/Context/BaseMinkContext.php
@@ -277,7 +277,7 @@ public function assertPageAddress($page)
/**
* Checks, that current page PATH matches regular expression.
*
- * @Then /^the url should match "(?P<pattern>(?:[^"]|\\")*)"$/
+ * @Then /^the (?i)url(?-i) should match "(?P<pattern>(?:[^"]|\\")*)"$/
*/
public function assertUrlRegExp($pattern)
{
@@ -588,10 +588,10 @@ public function assertCheckboxNotChecked($checkbox)
*/
public function assertNumElements($num, $element)
{
- $nodes = $world->getSession()->getPage()->findAll('css', $element);
+ $nodes = $this->getSession()->getPage()->findAll('css', $element);
if (null === $nodes) {
- throw new ElementNotFoundException($world->getSession(), 'element: '.$element.' ');
+ throw new ElementNotFoundException($this->getSession(), 'element: '.$element.' ');
}
assertSame((int) $num, count($nodes));
View
44 src/Behat/Mink/Behat/Context/MinkContext.php
@@ -9,7 +9,8 @@
Behat\Mink\Driver\GoutteDriver,
Behat\Mink\Driver\SahiDriver,
Behat\Mink\Driver\ZombieDriver,
- Behat\Mink\Driver\SeleniumDriver;
+ Behat\Mink\Driver\SeleniumDriver,
+ Behat\Mink\Driver\Selenium2Driver;
use Goutte\Client as GoutteClient;
@@ -133,9 +134,18 @@ protected static function registerMinkSessions(Mink $mink, array $parameters)
}
if (!$mink->hasSession('selenium')) {
- $params = $parameters['selenium'];
+ $params = $parameters['selenium'];
+ $browser = isset($params['browser']) ? $params['browser'] : '*'.$parameters['browser'];
$mink->registerSession('selenium', static::initSeleniumSession(
- $parameters['browser'], $parameters['base_url'], $params['host'], $params['port']
+ $browser, $parameters['base_url'], $params['host'], $params['port']
+ ));
+ }
+
+ if (!$mink->hasSession('webdriver')) {
+ $params = $parameters['webdriver'];
+ $browser = $parameters['browser'];
+ $mink->registerSession('selenium', static::initWebdriverSession(
+ $browser, $params['host']
));
}
}
@@ -192,18 +202,35 @@ 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
+ * @param string $browser browser info
+ * @param string $baseUrl selenium start url
+ * @param string $host selenium server server host
+ * @param integer $port port number
*
* @return Behat\Mink\Session
*/
- protected static function initSeleniumSession($browser, $baseUrl, $host, $port)
+ protected static function initSeleniumSession($browser = '*firefox',
+ $baseUrl = 'http://localhost',
+ $host = '127.0.0.1', $port = 4444)
{
return new Session(new SeleniumDriver($browser, $baseUrl, new SeleniumClient($host, $port)));
}
/**
+ * Initizalizes and returns new Selenium2Driver session.
+ *
+ * @param string $browser browser name
+ * @param string $host selenium server server host
+ *
+ * @return Behat\Mink\Session
+ */
+ protected static function initWebdriverSession($browser = 'firefox',
+ $host = 'http://localhost:4444/wd/hub')
+ {
+ return new Session(new Selenium2Driver($browser, null, $host));
+ }
+
+ /**
* Returns list of default parameters.
*
* @return array
@@ -236,6 +263,9 @@ protected static function getDefaultParameters()
'host' => 'localhost',
'port' => 4444
),
+ 'webdriver' => array(
+ 'host' => 'http://localhost:4444/wd/hub'
+ ),
);
}
View
66 src/Behat/Mink/Behat/Context/translations/es.xliff
@@ -4,72 +4,76 @@
<body>
<trans-unit id="i-am-on-page">
<source><![CDATA[/^(?:|I )am on "(?P<page>[^"]+)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )estoy en "(?P<page>[^"]+)"$/]]></target>
+ <target><![CDATA[/^estoy en "(?P<page>[^"]+)"$/]]></target>
</trans-unit>
<trans-unit id="i-go-to-page">
<source><![CDATA[/^(?:|I )go to "(?P<page>[^"]+)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )voy a "(?P<page>[^"]+)"$/]]></target>
+ <target><![CDATA[/^voy a "(?P<page>[^"]+)"$/]]></target>
</trans-unit>
<trans-unit id="reload-the-page">
<source><![CDATA[/^(?:|I )reload the page$/]]></source>
- <target><![CDATA[/^(?:|Yo )recargo la página$/]]></target>
+ <target><![CDATA[/^recargo la página$/]]></target>
</trans-unit>
<trans-unit id="move-backward-one-page">
<source><![CDATA[/^(?:|I )move backward one page$/]]></source>
- <target><![CDATA[/^(?:|Yo )voy hacia atrás una página$/]]></target>
+ <target><![CDATA[/^voy hacia atrás una página$/]]></target>
</trans-unit>
<trans-unit id="move-forward-one-page">
<source><![CDATA[/^(?:|I )move forward one page$/]]></source>
- <target><![CDATA[/^(?:|Yo )voy hacia adelante una página$/]]></target>
+ <target><![CDATA[/^voy hacia adelante una página$/]]></target>
</trans-unit>
<trans-unit id="i-press-button">
<source><![CDATA[/^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )presiono "(?P<button>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^presiono "(?P<button>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-follow-link">
<source><![CDATA[/^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )sigo "(?P<link>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^sigo "(?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[/^(?:|Yo )relleno "(?P<field>(?:[^"]|\\")*)" con "(?P<value>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^relleno "(?P<field>(?:[^"]|\\")*)" con "(?P<value>(?:[^"]|\\")*)"$/]]></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[/^(?:|Yo )relleno "(?P<value>(?:[^"]|\\")*)" para "(?P<field>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^relleno con "(?P<value>(?:[^"]|\\")*)" a "(?P<field>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-fill-in-the-following">
<source><![CDATA[/^(?:|I )fill in the following:$/]]></source>
- <target><![CDATA[/^(?:|Yo )relleno el siguiente:$/]]></target>
+ <target><![CDATA[/^relleno lo siguiente:$/]]></target>
</trans-unit>
<trans-unit id="i-select-option-from-select">
<source><![CDATA[/^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )selecciono "(?P<option>(?:[^"]|\\")*)" desde "(?P<select>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^selecciono "(?P<option>(?:[^"]|\\")*)" de "(?P<select>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-additionally-select-option-from-select">
+ <source><![CDATA[/^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^adicionalmente selecciono "(?P<option>(?:[^"]|\\")*)" de "(?P<select>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-check-option">
<source><![CDATA[/^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )chequeo "(?P<option>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^marco "(?P<option>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-uncheck-option">
<source><![CDATA[/^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )dechequeo "(?P<option>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^desmarco "(?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[/^(?:|Yo )adjunto el archivo "(?P<path>[^"]*)" a "(?P<field>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^adjunto el archivo "(?P<path>[^"]*)" a "(?P<field>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-should-see-text">
<source><![CDATA[/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )debo ver "(?P<text>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^debo ver "(?P<text>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-not-see-text">
+ <source><![CDATA[/^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^no debo ver "(?P<text>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="the-response-should-contain">
<source><![CDATA[/^the response should contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^la respuesta debe contener "(?P<text>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
- <trans-unit id="i-should-not-see-text">
- <source><![CDATA[/^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )no debo ver "(?P<text>(?:[^"]|\\")*)"$/]]></target>
- </trans-unit>
<trans-unit id="the-response-should-not-contain">
<source><![CDATA[/^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^la respuesta no debe contener "(?P<text>(?:[^"]|\\")*)"$/]]></target>
@@ -84,19 +88,19 @@
</trans-unit>
<trans-unit id="the-checkbox-should-be-checked">
<source><![CDATA[/^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/]]></source>
- <target><![CDATA[/^el checkbox "(?P<checkbox>[^"]*) debe estar seleccionado" $/]]></target>
+ <target><![CDATA[/^la casilla de selección "(?P<checkbox>[^"]*) debe estar marcada" $/]]></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[/^el checkbox "(?P<checkbox>(?:[^"]|\\")*)" no debe estar seleccionado$/]]></target>
+ <target><![CDATA[/^la casilla de selección "(?P<checkbox>(?:[^"]|\\")*)" no debe estar marcada$/]]></target>
</trans-unit>
<trans-unit id="i-should-be-on-page">
<source><![CDATA[/^(?:|I )should be on "(?P<page>[^"]+)"$/]]></source>
- <target><![CDATA[/^(?:|Yo )debo estar en "(?P<page>[^"]+)"$/]]></target>
+ <target><![CDATA[/^debo estar en "(?P<page>[^"]+)"$/]]></target>
</trans-unit>
<trans-unit id="the-url-should-match">
<source><![CDATA[/^the url should match "(?P<pattern>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^la url debe seguir el patrón "(?P<pattern>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^la URL debe seguir el patrón "(?P<pattern>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="the-element-should-contain">
<source><![CDATA[/^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
@@ -104,19 +108,27 @@
</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[/^(?:|Yo )debo ver "(?P<text>(?:[^"]|\\")*)" en el elemento "(?P<element>[^"]*)"$/]]></target>
+ <target><![CDATA[/^debo ver "(?P<text>(?:[^"]|\\")*)" en el elemento "(?P<element>[^"]*)"$/]]></target>
</trans-unit>
<trans-unit id="i-should-see-element">
<source><![CDATA[/^(?:|I )should see an? "(?P<element>[^"]*)" element$/]]></source>
- <target><![CDATA[/^(?:|Yo )debo ver un elemento "(?P<element>[^"]*)"$/]]></target>
+ <target><![CDATA[/^debo ver un elemento "(?P<element>[^"]*)"$/]]></target>
</trans-unit>
<trans-unit id="i-should-not-see-element">
<source><![CDATA[/^(?:|I )should not see an? "(?P<element>[^"]*)" element$/]]></source>
- <target><![CDATA[/^(?:|Yo )no debo ver un elemento "(?P<element>[^"]*)"$/]]></target>
+ <target><![CDATA[/^no debo ver un elemento "(?P<element>[^"]*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-see-num-elements">
+ <source><![CDATA[/^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/]]></source>
+ <target><![CDATA[/^debo ver (?P<num>\d+) "(?P<element>[^"]*)" elementos$/]]></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[/^el código de estado de la respuesta deve ser (?P<code>\d+)$/]]></target>
+ <target><![CDATA[/^el código de estado de la respuesta debe ser (?P<code>\d+)$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-response-status-code-should-not-be">
+ <source><![CDATA[/^the response status code should not be (?P<code>\d+)$/]]></source>
+ <target><![CDATA[/^el código de estado de la respuesta no debe ser (?P<code>\d+)$/]]></target>
</trans-unit>
<trans-unit id="print-last-response">
<source><![CDATA[/^print last response$/]]></source>
View
80 src/Behat/Mink/Behat/Context/translations/fr.xliff
@@ -3,12 +3,24 @@
<header />
<body>
<trans-unit id="i-am-on-page">
- <source><![CDATA[/^(?:|I )am on (?P<page>.+)$/]]></source>
- <target><![CDATA[/^(?:|je )suis sur (?P<page>.+)$/]]></target>
+ <source><![CDATA[/^(?:|I )am on "(?P<page>[^"]+)"$/]]></source>
+ <target><![CDATA[/^(?:|je )suis sur "(?P<page>[^"]+)"$/]]></target>
</trans-unit>
<trans-unit id="i-go-to-page">
- <source><![CDATA[/^(?:|I )go to (?P<page>.+)$/]]></source>
- <target><![CDATA[/^(?:|je )vais sur (?P<page>.+)$/]]></target>
+ <source><![CDATA[/^(?:|I )go to "(?P<page>[^"]+)"$/]]></source>
+ <target><![CDATA[/^(?:|je )vais sur "(?P<page>[^"]+)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="reload-the-page">
+ <source><![CDATA[/^(?:|I )reload the page$/]]></source>
+ <target><![CDATA[/^(?:|je )recharge la page$/]]></target>
+ </trans-unit>
+ <trans-unit id="move-backward-one-page">
+ <source><![CDATA[/^(?:|I )move backward one page$/]]></source>
+ <target><![CDATA[/^(?:|je )recule d'une page$/]]></target>
+ </trans-unit>
+ <trans-unit id="move-forward-one-page">
+ <source><![CDATA[/^(?:|I )move forward one page$/]]></source>
+ <target><![CDATA[/^(?:|j')avance d'une page$/]]></target>
</trans-unit>
<trans-unit id="i-press-button">
<source><![CDATA[/^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/]]></source>
@@ -34,6 +46,10 @@
<source><![CDATA[/^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|je )sélectionne "(?P<option>(?:[^"]|\\")*)" depuis "(?P<select>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
+ <trans-unit id="i-additionally-select-option-from-select">
+ <source><![CDATA[/^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^(?:|je )sélectionne une autre option "(?P<option>(?:[^"]|\\")*)" depuis "(?P<select>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
<trans-unit id="i-check-option">
<source><![CDATA[/^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|je )coche "(?P<option>(?:[^"]|\\")*)"$/]]></target>
@@ -50,10 +66,18 @@
<source><![CDATA[/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|je )devrais voir "(?P<text>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
+ <trans-unit id="the-response-should-contain">
+ <source><![CDATA[/^the response should contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^la réponse devrait contenir "(?P<text>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
<trans-unit id="i-should-not-see-text">
<source><![CDATA[/^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|je )ne devrais pas voir "(?P<text>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
+ <trans-unit id="the-response-should-not-contain">
+ <source><![CDATA[/^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^la réponse ne devrait pas contenir "(?P<text>(?:[^"]|\\")*)"$/]]></target>
+ </trans-unit>
<trans-unit id="the-field-should-contain-value">
<source><![CDATA[/^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^le champ "(?P<field>(?:[^"]|\\")*)" devrait contenir "(?P<value>(?:[^"]|\\")*)"$/]]></target>
@@ -64,35 +88,55 @@
</trans-unit>
<trans-unit id="the-checkbox-should-be-checked">
<source><![CDATA[/^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/]]></source>
- <target><![CDATA[/^la case à cocher "(?P<checkbox>[^"]*) devrait être cochée" $/]]></target>
+ <target><![CDATA[/^la case à cocher "(?P<checkbox>[^"]*)" devrait être cochée$/]]></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[/^la case à cocher "(?P<checkbox>(?:[^"]|\\")*)" ne devrait pas être cochée$/]]></target>
</trans-unit>
<trans-unit id="i-should-be-on-page">
- <source><![CDATA[/^(?:|I )should be on (?P<page>.+)$/]]></source>
- <target><![CDATA[/^(?:|je )devrais être sur (?P<page>.+)$/]]></target>
+ <source><![CDATA[/^(?:|I )should be on "(?P<page>[^"]+)"$/]]></source>
+ <target><![CDATA[/^(?:|je )devrais être sur "(?P<page>[^"]+)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="the-url-should-match">
+ <source><![CDATA[/^the url should match "(?P<pattern>(?:[^"]|\\")*)"$/]]></source>
+ <target><![CDATA[/^l'url devrait suivre le motif "(?P<pattern>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="the-element-should-contain">
<source><![CDATA[/^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^l'élement "(?P<element>[^"]*)" devrait contenir "(?P<value>(?:[^"]|\\")*)"$/]]></target>
+ <target><![CDATA[/^l'élément "(?P<element>[^"]*)" devrait contenir "(?P<value>(?:[^"]|\\")*)"$/]]></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[/^(?:|je )devrais voir "(?P<text>(?:[^"]|\\")*)" dans l'élément "(?P<element>[^"]*)"$/]]></target>
</trans-unit>
<trans-unit id="i-should-see-element">
<source><![CDATA[/^(?:|I )should see an? "(?P<element>[^"]*)" element$/]]></source>
- <target><![CDATA[/^(?:|je )devrais voir l'élement "(?P<element>[^"]*)"$/]]></target>
+ <target><![CDATA[/^(?:|je )devrais voir l'élément "(?P<element>[^"]*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-not-see-element">
+ <source><![CDATA[/^(?:|I )should not see an? "(?P<element>[^"]*)" element$/]]></source>
+ <target><![CDATA[/^(?:|je )ne devrais pas voir l'élément "(?P<element>[^"]*)"$/]]></target>
+ </trans-unit>
+ <trans-unit id="i-should-see-num-elements">
+ <source><![CDATA[/^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/]]></source>
+ <target><![CDATA[/^(?:|je )devrais voir (?P<num>\d+) éléments? "(?P<element>[^"]*)"$/]]></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[/^le code de status de la réponse devrait être (?P<code>\d+)$/]]></target>
</trans-unit>
- <trans-unit id="the-element-should-link-to">
- <source><![CDATA[/^the "(?P<element>[^"]*)" element should link to (?P<href>.*)$/]]></source>
- <target><![CDATA[/^l'élement "(?P<element>[^"]*)" devrait pointer vers (?P<href>.*)$/]]></target>
+ <trans-unit id="the-response-status-code-should-not-be">
+ <source><![CDATA[/^the response status code should not be (?P<code>\d+)$/]]></source>
+ <target><![CDATA[/^le code de status de la réponse ne devrait pas être (?P<code>\d+)$/]]></target>
</trans-unit>
- <trans-unit id="the-element-should-have-attribute-of">
- <source><![CDATA[/^the "(?P<element>[^"]*)" element should have a "(?P<attribute>[a-zA-Z\-\_]*)" attribute of "(?P<value>(?:[^"]|\\")*)"$/]]></source>
- <target><![CDATA[/^l'élement "(?P<element>[^"]*)" devrait avoir un attribut "(?P<attribute>[a-zA-Z\-\_]*)" de valeur "(?P<value>(?:[^"]|\\")*)"$/]]></target>
+ <trans-unit id="print-last-response">
+ <source><![CDATA[/^print last response$/]]></source>
+ <target><![CDATA[/^imprimer la dernière réponse$/]]></target>
</trans-unit>
- <trans-unit id="">
- <source><![CDATA[/the response status code should be (?P<code>\d+)/]]></source>
- <target><![CDATA[/le code du statut de la réponse devrait être (?P<code>\d+)/]]></target>
+ <trans-unit id="show-last-response">
+ <source><![CDATA[/^show last response$/]]></source>
+ <target><![CDATA[/^montrer la dernière réponse$/]]></target>
</trans-unit>
</body>
</file>
View
261 src/Behat/Mink/ClassLoader/UniversalClassLoader.php
@@ -1,261 +0,0 @@
-<?php
-
-namespace Behat\Mink\ClassLoader;
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * UniversalClassLoader implements a "universal" autoloader for PHP 5.3.
- *
- * It is able to load classes that use either:
- *
- * * The technical interoperability standards for PHP 5.3 namespaces and
- * class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
- *
- * * The PEAR naming convention for classes (http://pear.php.net/).
- *
- * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
- * looked for in a list of locations to ease the vendoring of a sub-set of
- * classes for large projects.
- *
- * Example usage:
- *
- * $loader = new UniversalClassLoader();
- *
- * // register classes with namespaces
- * $loader->registerNamespaces(array(
- * 'Symfony\Component' => __DIR__.'/component',
- * 'Symfony' => __DIR__.'/framework',
- * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
- * ));
- *
- * // register a library using the PEAR naming convention
- * $loader->registerPrefixes(array(
- * 'Swift_' => __DIR__.'/Swift',
- * ));
- *
- * // activate the autoloader
- * $loader->register();
- *
- * In this example, if you try to use a class in the Symfony\Component
- * namespace or one of its children (Symfony\Component\Console for instance),
- * the autoloader will first look for the class under the component/
- * directory, and it will then fallback to the framework/ directory if not
- * found before giving up.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @api
- */
-class UniversalClassLoader
-{
- private $namespaces = array();
- private $prefixes = array();
- private $namespaceFallbacks = array();
- private $prefixFallbacks = array();
-
- /**
- * Gets the configured namespaces.
- *
- * @return array A hash with namespaces as keys and directories as values
- */
- public function getNamespaces()
- {
- return $this->namespaces;
- }
-
- /**
- * Gets the configured class prefixes.
- *
- * @return array A hash with class prefixes as keys and directories as values
- */
- public function getPrefixes()
- {
- return $this->prefixes;
- }
-
- /**
- * Gets the directory(ies) to use as a fallback for namespaces.
- *
- * @return array An array of directories
- */
- public function getNamespaceFallbacks()
- {
- return $this->namespaceFallbacks;
- }
-
- /**
- * Gets the directory(ies) to use as a fallback for class prefixes.
- *
- * @return array An array of directories
- */
- public function getPrefixFallbacks()
- {
- return $this->prefixFallbacks;
- }
-
- /**
- * Registers the directory to use as a fallback for namespaces.
- *
- * @param array $dirs An array of directories
- *
- * @api
- */
- public function registerNamespaceFallbacks(array $dirs)
- {
- $this->namespaceFallbacks = $dirs;
- }
-
- /**
- * Registers the directory to use as a fallback for class prefixes.
- *
- * @param array $dirs An array of directories
- *
- * @api
- */
- public function registerPrefixFallbacks(array $dirs)
- {
- $this->prefixFallbacks = $dirs;
- }
-
- /**
- * Registers an array of namespaces
- *
- * @param array $namespaces An array of namespaces (namespaces as keys and locations as values)
- *
- * @api
- */
- public function registerNamespaces(array $namespaces)
- {
- foreach ($namespaces as $namespace => $locations) {
- $this->namespaces[$namespace] = (array) $locations;
- }
- }
-
- /**
- * Registers a namespace.
- *
- * @param string $namespace The namespace
- * @param array|string $paths The location(s) of the namespace
- *
- * @api
- */
- public function registerNamespace($namespace, $paths)
- {
- $this->namespaces[$namespace] = (array) $paths;
- }
-
- /**
- * Registers an array of classes using the PEAR naming convention.
- *
- * @param array $classes An array of classes (prefixes as keys and locations as values)
- *
- * @api
- */
- public function registerPrefixes(array $classes)
- {
- foreach ($classes as $prefix => $locations) {
- $this->prefixes[$prefix] = (array) $locations;
- }
- }
-
- /**
- * Registers a set of classes using the PEAR naming convention.
- *
- * @param string $prefix The classes prefix
- * @param array|string $paths The location(s) of the classes
- *
- * @api
- */
- public function registerPrefix($prefix, $paths)
- {
- $this->prefixes[$prefix] = (array) $paths;
- }
-
- /**
- * Registers this instance as an autoloader.
- *
- * @param Boolean $prepend Whether to prepend the autoloader or not
- *
- * @api
- */
- public function register($prepend = false)
- {
- spl_autoload_register(array($this, 'loadClass'), true, $prepend);
- }
-
- /**
- * Loads the given class or interface.
- *
- * @param string $class The name of the class
- */
- public function loadClass($class)
- {
- if ($file = $this->findFile($class)) {
- require $file;
- }
- }
-
- /**
- * Finds the path to the file where the class is defined.
- *
- * @param string $class The name of the class
- *
- * @return string|null The path, if found
- */
- public function findFile($class)
- {
- if ('\\' == $class[0]) {
- $class = substr($class, 1);
- }
-
- if (false !== $pos = strrpos($class, '\\')) {
- // namespaced class name
- $namespace = substr($class, 0, $pos);
- foreach ($this->namespaces as $ns => $dirs) {
- foreach ($dirs as $dir) {
- if (0 === strpos($namespace, $ns)) {
- $className = substr($class, $pos + 1);
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
- if (file_exists($file)) {
- return $file;
- }
- }
- }
- }
-
- foreach ($this->namespaceFallbacks as $dir) {
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
- if (file_exists($file)) {
- return $file;
- }
- }
- } else {
- // PEAR-like class name
- foreach ($this->prefixes as $prefix => $dirs) {
- foreach ($dirs as $dir) {
- if (0 === strpos($class, $prefix)) {
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
- if (file_exists($file)) {
- return $file;
- }
- }
- }
- }
-
- foreach ($this->prefixFallbacks as $dir) {
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
- if (file_exists($file)) {
- return $file;
- }
- }
- }
- }
-}
View
98 src/Behat/Mink/Compiler/MapFileCompiler.php
@@ -46,103 +46,23 @@ public function compile($autoloaderFilename = 'autoload.php', $mapFilename = 'au
}
$mappings = '';
- foreach ($this->findPhpFile()->in($this->libPath . '/src') as $file) {
- $path = str_replace($this->libPath . '/src/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= "\$mappings['$class'] = \$minkDir . 'src/$path';\n";
- }
-
- // autoload Goutte
- $mappings .= "\nif (!defined('BEHAT_AUTOLOAD_GOUTTE') || true === BEHAT_AUTOLOAD_GOUTTE) {\n";
- $mappings .= " \$mappings['Goutte\Client'] = __DIR__ . '/vendor/Goutte/src/Goutte/Client.php';\n";
- $mappings .= "}\n";
-
- // autoload SahiClient
- $mappings .= "\nif (!defined('BEHAT_AUTOLOAD_SAHI') || true === BEHAT_AUTOLOAD_SAHI) {\n";
- foreach ($this->findPhpFile()->in($this->libPath . '/vendor/SahiClient/src') as $file) {
- $path = str_replace($this->libPath . '/vendor/SahiClient/src/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = __DIR__ . '/vendor/SahiClient/src/$path';\n";
- }
- $mappings .= "}\n";
-
- // autoload php-selenium
- $mappings .= "\nif (!defined('BEHAT_AUTOLOAD_SELENIUM') || true === BEHAT_AUTOLOAD_SELENIUM) {\n";
- foreach ($this->findPhpFile()->in($this->libPath . '/vendor/php-selenium/src') as $file) {
- $path = str_replace($this->libPath . '/vendor/php-selenium/src/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = __DIR__ . '/vendor/php-selenium/src/$path';\n";
- }
- $mappings .= "}\n";
-
- // autoload Buzz
- $mappings .= "\nif (!defined('BEHAT_AUTOLOAD_BUZZ') || true === BEHAT_AUTOLOAD_BUZZ) {\n";
- foreach ($this->findPhpFile()->in($this->libPath . '/vendor/Buzz/lib') as $file) {
- $path = str_replace($this->libPath . '/vendor/Buzz/lib/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = __DIR__ . '/vendor/Buzz/lib/$path';\n";
- }
- $mappings .= "}\n";
-
// autoload Symfony2
$mappings .= "\nif (!defined('BEHAT_AUTOLOAD_SF2') || true === BEHAT_AUTOLOAD_SF2) {\n";
- foreach ($this->findPhpFile()->in($this->libPath . '/vendor/Symfony') as $file) {
- $path = str_replace($this->libPath . '/vendor/', '', $file->getRealPath());
+ foreach ($this->findPhpFile()->in($this->libPath . '/vendor/symfony') as $file) {
+ $path = str_replace(array(
+ $this->libPath . '/vendor/symfony/browser-kit/',
+ $this->libPath . '/vendor/symfony/css-selector/',
+ $this->libPath . '/vendor/symfony/dom-crawler/',
+ $this->libPath . '/vendor/symfony/process/',
+ ), '', $file->getRealPath());
$class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = \$symfonyDir . '$path';\n";
- }
- $mappings .= "}\n";
-
- // autoload ZF2
- $mappings .= "\nif (!defined('BEHAT_AUTOLOAD_ZF2') || true === BEHAT_AUTOLOAD_ZF2) {\n";
- $zendDir = $this->libPath . '/vendor/Goutte/vendor/zend/library';
- foreach (array(
- 'Zend\Tool\Framework\Exception',
- 'Zend\Registry',
- 'Zend\Uri\Uri',
- 'Zend\Validator\Validator',
- 'Zend\Validator\AbstractValidator',
- 'Zend\Validator\Hostname',
- 'Zend\Validator\Ip',
- 'Zend\Validator\Hostname\Com',
- 'Zend\Validator\Hostname\Jp',
- ) as $class) {
- $path = str_replace('\\', '/', $class) . '.php';
- $mappings .= " \$mappings['$class'] = \$zendDir . '$path';\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Uri') as $file) {
- $path = str_replace($zendDir . '/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = \$zendDir . '$path';\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Http') as $file) {
- $path = str_replace($zendDir . '/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = \$zendDir . '$path';\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Stdlib') as $file) {
- $path = str_replace($zendDir . '/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = \$zendDir . '$path';\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Loader') as $file) {
- $path = str_replace($zendDir . '/', '', $file->getRealPath());
- $class = str_replace(array('/', '.php'), array('\\', ''), $path);
- $mappings .= " \$mappings['$class'] = \$zendDir . '$path';\n";
+ $mappings .= " \$mappings['$class'] = '$path';\n";
}
$mappings .= "}\n";
$mapContent = <<<MAP_FILE
<?php
-\$minkDir = __DIR__ . '/';
-\$zendDir = __DIR__ . '/vendor/Goutte/vendor/zend/library/';
-if (is_dir(__DIR__ . '/vendor/Symfony/')) {
- \$symfonyDir = __DIR__ . '/vendor/';
-} else {
- \$symfonyDir = '';
-}
-
\$mappings = array();
$mappings
return \$mappings;
@@ -181,6 +101,8 @@ protected function getAutoloadScript($mapFilename)
$loader = new MapFileClassLoader(__DIR__ . '/%s');
$loader->register();
+require_once __DIR__ . '/vendor/.composer/autoload.php';
+
EOF
, $mapFilename);
}
View
97 src/Behat/Mink/Compiler/PearCompiler.php
@@ -52,58 +52,56 @@ public function compile($version, $stability)
->name('*.php')
->name('*.xliff')
->name('*.xml')
+ ->name('*.js')
->name('*.feature')
->name('LICENSE')
- ->notName('PharCompiler.php')
- ->notName('PearCompiler.php')
- ->notName('Compiler.php')
+ ->name('LICENSE.txt')
+ ->notName('test')
+ ->notName('tests')
+ ->exclude(array(
+ 'Compiler',
+ 'finder',
+ 'test',
+ 'tests',
+ 'vendor',
+ ))
->in($this->libPath . '/src')
- ->in($this->libPath . '/features')
- ->in($this->libPath . '/tests')
- ->in($this->libPath . '/vendor/Buzz/lib')
- ->in($this->libPath . '/vendor/Goutte/src')
- ->in($this->libPath . '/vendor/SahiClient/src')
- ->in($this->libPath . '/vendor/php-selenium/src');
+ ->in($this->libPath . '/vendor/.composer')
+ ->in($this->libPath . '/vendor/alexandresalome')
+ ->in($this->libPath . '/vendor/behat')
+ ->in($this->libPath . '/vendor/fabpot')
+ ->in($this->libPath . '/vendor/facebook')
+ ->in($this->libPath . '/vendor/kriswallsmith')
+ ->in($this->libPath . '/vendor/zendframework/zend-uri')
+ ->in($this->libPath . '/vendor/zendframework/zend-http')
+ ;
+
+ $files = array(
+ $this->libPath . '/vendor/zendframework/zend-registry/php/Zend/Registry.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Validator.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/AbstractValidator.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Hostname.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Ip.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Hostname/Com.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Hostname/Jp.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/Dispatchable.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/Message.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/MessageDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/RequestDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/Parameters.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/ParametersDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/ResponseDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-loader/php/Zend/Loader/PluginClassLoader.php',
+ $this->libPath . '/vendor/zendframework/zend-loader/php/Zend/Loader/PluginClassLocator.php',
+ $this->libPath . '/vendor/zendframework/zend-loader/php/Zend/Loader/ShortNameLocator.php',
+ );
$xmlSourceFiles = '';
- foreach ($finder as $file) {
- $path = str_replace($this->libPath . '/', '', $file->getRealPath());
- $xmlSourceFiles .=
- '<file role="php" baseinstalldir="mink" install-as="'.$path.'" name="'.$path.'" />'."\n";
- }
+ foreach (array_merge($files, iterator_to_array($finder)) as $file) {
+ if (!$file instanceof \SplFileInfo) {
+ $file = new \SplFileInfo($file);
+ }
- $zendDir = $this->libPath . '/vendor/Goutte/vendor/zend/library/';
- foreach (array(
- 'Zend\Tool\Framework\Exception',
- 'Zend\Registry',
- 'Zend\Uri\Uri',
- 'Zend\Validator\Validator',
- 'Zend\Validator\AbstractValidator',
- 'Zend\Validator\Hostname',
- 'Zend\Validator\Ip',
- 'Zend\Validator\Hostname\Com',
- 'Zend\Validator\Hostname\Jp',
- ) as $class) {
- $path = 'vendor/Goutte/vendor/zend/library/' . str_replace('\\', '/', $class) . '.php';
- $xmlSourceFiles .=
- '<file role="php" baseinstalldir="mink" install-as="'.$path.'" name="'.$path.'" />'."\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Uri') as $file) {
- $path = str_replace($this->libPath . '/', '', $file->getRealPath());
- $xmlSourceFiles .=
- '<file role="php" baseinstalldir="mink" install-as="'.$path.'" name="'.$path.'" />'."\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Stdlib') as $file) {
- $path = str_replace($this->libPath . '/', '', $file->getRealPath());
- $xmlSourceFiles .=
- '<file role="php" baseinstalldir="mink" install-as="'.$path.'" name="'.$path.'" />'."\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Http') as $file) {
- $path = str_replace($this->libPath . '/', '', $file->getRealPath());
- $xmlSourceFiles .=
- '<file role="php" baseinstalldir="mink" install-as="'.$path.'" name="'.$path.'" />'."\n";
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Loader') as $file) {
$path = str_replace($this->libPath . '/', '', $file->getRealPath());
$xmlSourceFiles .=
'<file role="php" baseinstalldir="mink" install-as="'.$path.'" name="'.$path.'" />'."\n";
@@ -183,15 +181,8 @@ protected function getPackageTemplate()
<dir name="/">
##SOURCE_FILES##
- <file role="php" baseinstalldir="mink" install-as="vendor/Buzz/LICENSE" name="vendor/Buzz/LICENSE" />
- <file role="php" baseinstalldir="mink" install-as="vendor/Goutte/LICENSE" name="vendor/Goutte/LICENSE" />
- <file role="php" baseinstalldir="mink" install-as="vendor/SahiClient/LICENSE" name="vendor/SahiClient/LICENSE" />
- <file role="php" baseinstalldir="mink" install-as="vendor/Goutte/vendor/zend/LICENSE.txt" name="vendor/Goutte/vendor/zend/LICENSE.txt" />
-
<file role="php" baseinstalldir="mink" name="autoload.php" />
<file role="php" baseinstalldir="mink" name="autoload_map.php" />
- <file role="php" baseinstalldir="mink" name="behat.yml" />
- <file role="php" baseinstalldir="mink" name="phpunit.xml.dist" />
<file role="php" baseinstalldir="mink" name="CHANGES.md" />
<file role="php" baseinstalldir="mink" name="LICENSE" />
<file role="php" baseinstalldir="mink" name="README.md" />
View
120 src/Behat/Mink/Compiler/PharCompiler.php
@@ -54,71 +54,60 @@ public function compile($version)
$finder->files()
->ignoreVCS(true)
->name('*.php')
- ->name('*.xml')
->name('*.xliff')
+ ->name('*.xml')
+ ->name('*.js')
+ ->name('*.feature')
->name('LICENSE')
- ->notName('PharCompiler.php')
- ->notName('PearCompiler.php')
- ->notName('Compiler.php')
+ ->name('LICENSE.txt')
+ ->notName('test')
+ ->notName('tests')
+ ->exclude(array(
+ 'Compiler',
+ 'finder',
+ 'test',
+ 'tests',
+ 'vendor',
+ ))
->in($this->libPath . '/src')
- ->in($this->libPath . '/vendor/Symfony/Component/BrowserKit')
- ->in($this->libPath . '/vendor/Symfony/Component/CssSelector')
- ->in($this->libPath . '/vendor/Symfony/Component/DomCrawler')
- ->in($this->libPath . '/vendor/Symfony/Component/Process')
- ->in($this->libPath . '/vendor/Buzz/lib')
- ->in($this->libPath . '/vendor/Goutte/src')
- ->in($this->libPath . '/vendor/SahiClient/src')
- ->in($this->libPath . '/vendor/php-selenium/src');
-
- foreach ($finder as $file) {
- // don't compile test suites
- if (!preg_match('/\/tests\/|\/test\//', $file->getRealPath())) {
- $this->addFileToPhar($file, $phar);
+ ->in($this->libPath . '/vendor/.composer')
+ ->in($this->libPath . '/vendor/symfony')
+ ->in($this->libPath . '/vendor/alexandresalome')
+ ->in($this->libPath . '/vendor/behat')
+ ->in($this->libPath . '/vendor/fabpot')
+ ->in($this->libPath . '/vendor/facebook')
+ ->in($this->libPath . '/vendor/kriswallsmith')
+ ->in($this->libPath . '/vendor/zendframework/zend-uri')
+ ->in($this->libPath . '/vendor/zendframework/zend-http')
+ ;
+
+ $files = array(
+ $this->libPath . '/vendor/zendframework/zend-registry/php/Zend/Registry.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Validator.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/AbstractValidator.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Hostname.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Ip.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Hostname/Com.php',
+ $this->libPath . '/vendor/zendframework/zend-validator/php/Zend/Validator/Hostname/Jp.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/Dispatchable.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/Message.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/MessageDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/RequestDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/Parameters.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/ParametersDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-stdlib/php/Zend/Stdlib/ResponseDescription.php',
+ $this->libPath . '/vendor/zendframework/zend-loader/php/Zend/Loader/PluginClassLoader.php',
+ $this->libPath . '/vendor/zendframework/zend-loader/php/Zend/Loader/PluginClassLocator.php',
+ $this->libPath . '/vendor/zendframework/zend-loader/php/Zend/Loader/ShortNameLocator.php',
+ );
+
+ foreach (array_merge($files, iterator_to_array($finder)) as $file) {
+ if (!$file instanceof \SplFileInfo) {
+ $file = new \SplFileInfo($file);
}
- }
- $zendDir = $this->libPath . '/vendor/Goutte/vendor/zend/library/';
- foreach (array(
- 'Zend\Tool\Framework\Exception',
- 'Zend\Registry',
- 'Zend\Uri\Uri',
- 'Zend\Validator\Validator',
- 'Zend\Validator\AbstractValidator',
- 'Zend\Validator\Hostname',
- 'Zend\Validator\Ip',
- 'Zend\Validator\Hostname\Com',
- 'Zend\Validator\Hostname\Jp',
- ) as $class) {
- $path = str_replace('\\', '/', $class) . '.php';
- $this->addFileToPhar(new \SplFileInfo($zendDir . $path), $phar);
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Uri') as $file) {
- $this->addFileToPhar($file, $phar);
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Http') as $file) {
$this->addFileToPhar($file, $phar);
}
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Stdlib') as $file) {
- $this->addFileToPhar($file, $phar);
- }
- foreach ($this->findPhpFile()->in($zendDir . '/Zend/Loader') as $file) {
- $this->addFileToPhar($file, $phar);
- }
-
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/LICENSE'), $phar);
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/autoload.php'), $phar);
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/autoload_map.php'), $phar);
-
- // license and autoloading
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/LICENSE'), $phar);
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/autoload.php'), $phar);
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/autoload_map.php'), $phar);
-
- // 3rd-party licenses
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/vendor/Goutte/LICENSE'), $phar);
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/vendor/Buzz/LICENSE'), $phar);
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/vendor/SahiClient/LICENSE'), $phar);
- $this->addFileToPhar(new \SplFileInfo($this->libPath . '/vendor/Goutte/vendor/zend/LICENSE.txt'), $phar);
// stub
$phar->setStub($this->getStub($version));
@@ -160,22 +149,11 @@ protected function getStub($version)
*/
Phar::mapPhar('mink.phar');
-require_once 'phar://mink.phar/autoload.php';
+require_once 'phar://mink.phar/vendor/facebook/php-webdriver/__init__.php';
+require_once 'phar://mink.phar/vendor/.composer/autoload.php';
__HALT_COMPILER();
EOF
, $version);
}
-
- /**
- * Creates finder instance to search php files.
- *
- * @return Symfony\Component\Finder\Finder
- */
- private function findPhpFile()
- {
- $finder = new Finder();
-
- return $finder->files()->ignoreVCS(true)->name('*.php');
- }
}
View
167 src/Behat/Mink/Driver/GoutteDriver.php
@@ -6,7 +6,8 @@
Symfony\Component\BrowserKit\Client,
Symfony\Component\BrowserKit\Cookie,
Symfony\Component\DomCrawler\Crawler,
- Symfony\Component\DomCrawler\Field\ChoiceFormField;
+ Symfony\Component\DomCrawler\Form,
+ Symfony\Component\DomCrawler\Field;
use Behat\Mink\Session,
Behat\Mink\Element\NodeElement,
@@ -90,6 +91,7 @@ public function stop()
{
$this->client->restart();
$this->started = false;
+ $this->forms = array();
}
/**
@@ -98,6 +100,7 @@ public function stop()
public function reset()
{
$this->client->restart();
+ $this->forms = array();
}
/**
@@ -123,6 +126,7 @@ public function getCurrentUrl()
public function reload()
{
$this->client->reload();
+ $this->forms = array();
}
/**
@@ -131,6 +135,7 @@ public function reload()
public function forward()
{
$this->client->forward();
+ $this->forms = array();
}
/**
@@ -139,6 +144,7 @@ public function forward()
public function back()
{
$this->client->back();
+ $this->forms = array();
}
/**
@@ -276,14 +282,14 @@ public function getAttribute($xpath, $attr)
public function getValue($xpath)
{
try {
- $field = $this->getField($xpath);
+ $field = $this->getFormField($xpath);
} catch (\InvalidArgumentException $e) {
return $this->getAttribute($xpath, 'value');
}
$value = $field->getValue();
- if ($field instanceof ChoiceFormField && 'checkbox' === $field->getType()) {
+ if ($field instanceof Field\ChoiceFormField && 'checkbox' === $field->getType()) {
$value = '1' == $value;
}
@@ -295,7 +301,7 @@ public function getValue($xpath)
*/
public function setValue($xpath, $value)
{
- $this->getField($xpath)->setValue($value);
+ $this->getFormField($xpath)->setValue($value);
}
/**
@@ -303,7 +309,7 @@ public function setValue($xpath, $value)
*/
public function check($xpath)
{
- $this->getField($xpath)->tick();
+ $this->getFormField($xpath)->tick();
}
/**
@@ -311,7 +317,7 @@ public function check($xpath)
*/
public function uncheck($xpath)
{
- $this->getField($xpath)->untick();
+ $this->getFormField($xpath)->untick();
}
/**
@@ -319,7 +325,7 @@ public function uncheck($xpath)
*/
public function selectOption($xpath, $value, $multiple = false)
{
- $field = $this->getField($xpath);
+ $field = $this->getFormField($xpath);
if ($multiple) {
$oldValue = (array) $field->getValue();
@@ -346,15 +352,14 @@ public function click($xpath)
if ('a' === $type) {
$this->client->click($node->link());
} elseif('input' === $type || 'button' === $type) {
- $buttonForm = $node->form();
- foreach ($this->forms as $form) {
- if ($buttonForm->getFormNode()->getLineNo() === $form->getFormNode()->getLineNo()) {
- $buttonForm = $form;
+ $form = $node->form();
+ $formId = $this->getFormNodeId($form->getFormNode());
- break;
- }
+ if (isset($this->forms[$formId])) {
+ $this->mergeForms($form, $this->forms[$formId]);
}
- $this->client->submit($buttonForm);
+
+ $this->client->submit($form);
} else {
throw new DriverException(sprintf(
'Goutte driver supports clicking on inputs and links only. But "%s" provided', $type
@@ -377,7 +382,7 @@ public function isChecked($xpath)
*/
public function attachFile($xpath, $path)
{
- $this->getField($xpath)->upload($path);
+ $this->getFormField($xpath)->upload($path);
}
/**
@@ -511,32 +516,13 @@ public function dragTo($sourceXpath, $destinationXpath)
}
/**
- * Returns DOMNode from crawler instance.
- *
- * @param Symfony\Component\DomCrawler\Crawler $crawler
- * @param integer $num number of node from crawler
- *
- * @return DOMNode
- */
- private function getCrawlerNode(Crawler $crawler, $num = 0)
- {
- foreach ($crawler as $i => $node) {
- if ($num == $i) {
- return $node;
- }
- }
-
- return null;
- }
-
- /**
* Returns form field from XPath query.
*
* @param string $xpath
*
* @return Symfony\Component\DomCrawler\Field\FormField
*/
- private function getField($xpath)
+ private function getFormField($xpath)
{
if (!count($crawler = $this->getCrawler()->filterXPath($xpath))) {
throw new ElementNotFoundException(
@@ -544,73 +530,112 @@ private function getField($xpath)
);
}
- $fieldNode = $this->getCrawlerNode($crawler);
- $formNode = $fieldNode;
+ $fieldNode = $this->getCrawlerNode($crawler);
+ $fieldName = str_replace('[]', '', $fieldNode->getAttribute('name'));
+ $formNode = $fieldNode;
do {
// use the ancestor form element
if (null === $formNode = $formNode->parentNode) {
- throw new ElementNotFoundException(
- $this->session, 'the form field with xpath "'.$xpath.'" was found, but no form element surrounding that field could be found'
- );
+ throw new \LogicException('The selected node does not have a form ancestor.');
}
} while ('form' != $formNode->nodeName);
- // check if form already exists
- foreach ($this->forms as $form) {
- if ($formNode->getLineNo() === $form->getFormNode()->getLineNo()) {
- $fieldName = $fieldNode->getAttribute('name');
- $fieldName = preg_replace('/\[\]$/', '', $fieldName);
+ $formId = $this->getFormNodeId($formNode);
- return $form[$fieldName];
- }
+ // check if form already exists
+ if (isset($this->forms[$formId])) {
+ return $this->forms[$formId][$fieldName];
}
// find form button
- $buttonNode = $this->findFormButton($formNode);
- if (null === $buttonNode) {
+ if (null === $buttonNode = $this->findFormButton($formNode)) {
throw new ElementNotFoundException(
$this->session, 'form submit button for field with xpath "'.$xpath.'"'
);
}
- $base = $this->client->getCrawler()->filter('base')->extract(array('href'));
- if (count($base)) {
- $base = current($base);
- } else {
- $base = NULL;
- }
-
- // init form
- $button = new Crawler(
- $buttonNode,
- $this->client->getRequest()->getUri(),
- $base
- );
+ $this->forms[$formId] = new Form($buttonNode, $this->client->getRequest()->getUri());
- $this->forms[] = $form = $button->form();
+ return $this->forms[$formId][$fieldName];
+ }
- return $form[$fieldNode->getAttribute('name')];
+ /**
+ * Returns form node unique identifier.
+ *
+ * @param \DOMElement $form
+ *
+ * @return mixed
+ */
+ private function getFormNodeId(\DOMElement $form)
+ {
+ return md5($form->getLineNo() . $form->getNodePath() . $form->nodeValue);
}
/**
* Finds form submit button inside form node.
*
- * @param DOMNode $form
+ * @param \DOMElement $form
*
- * @return DOMNode button node
+ * @return \DOMElement
*/
- private function findFormButton(\DOMNode $form)
+ private function findFormButton(\DOMElement $form)
{
- $document = new \DOMDocument('1.0', 'UTF-8');
- $node = $document->importNode($form, true);
- $root = $document->appendChild($document->createElement('_root'));
+ $document = new \DOMDocument('1.0', 'UTF-8');
+ $node = $document->importNode($form, true);
+ $root = $document->appendChild($document->createElement('_root'));
$root->appendChild($node);
$xpath = new \DOMXPath($document);
foreach ($xpath->query('descendant::input | descendant::button', $root) as $node) {
- if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) {
+ if ('button' == $node->nodeName || in_array($node->getAttribute('type'), array('submit', 'button', 'image'))) {
+ return $node;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Merges second form values into first one.
+ *
+ * @param Form $to merging target
+ * @param Form $from merging source
+ */
+ private function mergeForms(Form $to, Form $from)
+ {
+ foreach ($from->all() as $name => $field) {
+ $fieldReflection = new \ReflectionObject($field);
+ $nodeReflection = $fieldReflection->getProperty('node');
+ $valueReflection = $fieldReflection->getProperty('value');
+
+ $nodeReflection->setAccessible(true);
+ $valueReflection->setAccessible(true);
+
+ if (!($field instanceof Field\InputtoField && in_array(
+ $nodeReflection->getValue($field)->getAttribute('type'),
+ array('submit', 'button', 'image')
+ ))) {
+ $valueReflection->setValue(
+ $to[$field->getName()], $valueReflection->getValue($field)
+ );
+ }
+ }
+ }
+