From f00cd0bdf792f961e8ef45d342ab90b59ab4d6e8 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 6 Oct 2015 11:58:30 -0400 Subject: [PATCH] Updated Mink. --- composer.json | 2 +- composer.lock | 41 +-- vendor/behat/mink-zombie-driver/.travis.yml | 46 +++- vendor/behat/mink-zombie-driver/CHANGELOG.md | 23 ++ vendor/behat/mink-zombie-driver/README.md | 20 +- vendor/behat/mink-zombie-driver/composer.json | 13 +- .../behat/mink-zombie-driver/phpunit.xml.dist | 3 +- .../Mink/Driver => }/NodeJS/Connection.php | 0 .../{Behat/Mink/Driver => }/NodeJS/Server.php | 0 .../NodeJS/Server/ZombieServer.php | 0 .../{Behat/Mink/Driver => }/ZombieDriver.php | 55 ++-- .../mink-zombie-driver/tests/ZombieConfig.php | 3 +- vendor/behat/mink/.travis.yml | 19 +- vendor/behat/mink/CHANGES.md | 42 +++ vendor/behat/mink/LICENSE | 2 +- vendor/behat/mink/composer.json | 8 +- .../driver-testsuite/tests/AbstractConfig.php | 2 +- .../tests/Basic/BestPracticesTest.php | 84 ++++++ .../tests/Basic/ContentTest.php | 12 + .../tests/Basic/CookieTest.php | 3 +- .../tests/Basic/ErrorHandlingTest.php | 3 + .../tests/Basic/HeaderTest.php | 3 +- .../tests/Basic/NavigationTest.php | 8 +- .../tests/Basic/TraversingTest.php | 38 +-- .../tests/Basic/VisibilityTest.php | 2 +- .../tests/Form/CheckboxTest.php | 4 +- .../tests/Form/GeneralTest.php | 22 +- .../tests/Form/SelectTest.php | 5 +- .../tests/Js/ChangeEventTest.php | 7 +- .../driver-testsuite/tests/Js/EventsTest.php | 2 +- .../tests/Js/JavascriptEvaluationTest.php | 4 +- .../tests/Js/JavascriptTest.php | 2 +- .../driver-testsuite/tests/Js/WindowTest.php | 8 +- .../mink/driver-testsuite/tests/TestCase.php | 19 +- .../web-fixtures/element_change_detector.html | 2 +- .../driver-testsuite/web-fixtures/index.html | 4 + .../web-fixtures/issue225.html | 2 +- .../web-fixtures/js_test.html | 14 +- vendor/behat/mink/src/Driver/CoreDriver.php | 30 ++- .../behat/mink/src/Driver/DriverInterface.php | 36 +-- .../mink/src/Element/DocumentElement.php | 4 +- vendor/behat/mink/src/Element/Element.php | 19 +- .../mink/src/Element/ElementInterface.php | 3 +- vendor/behat/mink/src/Element/NodeElement.php | 26 +- .../mink/src/Element/TraversableElement.php | 36 +-- .../mink/src/Exception/ElementException.php | 6 +- .../src/Exception/ElementHtmlException.php | 15 +- .../Exception/ElementNotFoundException.php | 13 +- .../src/Exception/ExpectationException.php | 56 +++- .../src/Exception/ResponseTextException.php | 2 +- vendor/behat/mink/src/Mink.php | 2 +- .../behat/mink/src/Selector/NamedSelector.php | 37 ++- .../mink/src/Selector/SelectorsHandler.php | 12 +- .../behat/mink/src/Selector/Xpath/Escaper.php | 2 +- vendor/behat/mink/src/Session.php | 47 +++- vendor/behat/mink/src/WebAssert.php | 170 +++++++++--- .../mink/tests/Driver/CoreDriverTest.php | 34 +++ .../tests/Element/DocumentElementTest.php | 3 + .../behat/mink/tests/Element/ElementTest.php | 7 +- .../mink/tests/Element/NodeElementTest.php | 19 +- .../tests/Exception/ElementExceptionTest.php | 3 + .../Exception/ElementHtmlExceptionTest.php | 17 +- .../ElementNotFoundExceptionTest.php | 24 +- .../Exception/ElementTextExceptionTest.php | 17 +- .../Exception/ExpectationExceptionTest.php | 62 ++--- .../Exception/ResponseTextExceptionTest.php | 34 +-- .../mink/tests/Selector/NamedSelectorTest.php | 22 +- .../tests/Selector/SelectorsHandlerTest.php | 8 +- .../mink/tests/Selector/fixtures/test.html | 2 + vendor/behat/mink/tests/SessionTest.php | 23 ++ vendor/behat/mink/tests/WebAssertTest.php | 164 ++++++++++++ vendor/composer/autoload_namespaces.php | 1 - vendor/composer/autoload_psr4.php | 1 + vendor/composer/installed.json | 241 +++++++++--------- 74 files changed, 1193 insertions(+), 532 deletions(-) mode change 100755 => 100644 vendor/behat/mink-zombie-driver/README.md rename vendor/behat/mink-zombie-driver/src/{Behat/Mink/Driver => }/NodeJS/Connection.php (100%) rename vendor/behat/mink-zombie-driver/src/{Behat/Mink/Driver => }/NodeJS/Server.php (100%) rename vendor/behat/mink-zombie-driver/src/{Behat/Mink/Driver => }/NodeJS/Server/ZombieServer.php (100%) rename vendor/behat/mink-zombie-driver/src/{Behat/Mink/Driver => }/ZombieDriver.php (95%) create mode 100644 vendor/behat/mink/driver-testsuite/tests/Basic/BestPracticesTest.php diff --git a/composer.json b/composer.json index 9d37d5d82fd..91b984b96a0 100644 --- a/composer.json +++ b/composer.json @@ -67,7 +67,7 @@ "zf-commons/zfc-rbac": "~2.4" }, "require-dev": { - "behat/mink": "1.6.*", + "behat/mink": "1.7.*", "behat/mink-zombie-driver": "*" } } diff --git a/composer.lock b/composer.lock index 1f3d412bff1..b7c4a4a59da 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "1723bad3925fc92b726a16829ea9e8ac", + "hash": "9b1e17327dcdad44d8172432e9ba45f1", "packages": [ { "name": "aferrandini/phpqrcode", @@ -1127,21 +1127,24 @@ "packages-dev": [ { "name": "behat/mink", - "version": "v1.6.1", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/minkphp/Mink.git", - "reference": "8b68523a339ec991bcd638b39dc8f04f808da88a" + "reference": "6c129030ec2cc029905cf969a56ca8f087b2dfdf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/minkphp/Mink/zipball/8b68523a339ec991bcd638b39dc8f04f808da88a", - "reference": "8b68523a339ec991bcd638b39dc8f04f808da88a", + "url": "https://api.github.com/repos/minkphp/Mink/zipball/6c129030ec2cc029905cf969a56ca8f087b2dfdf", + "reference": "6c129030ec2cc029905cf969a56ca8f087b2dfdf", "shasum": "" }, "require": { "php": ">=5.3.1", - "symfony/css-selector": "~2.0" + "symfony/css-selector": "~2.1" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" }, "suggest": { "behat/mink-browserkit-driver": "extremely fast headless driver for Symfony\\Kernel-based apps (Sf2, Silex)", @@ -1152,7 +1155,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -1178,36 +1181,40 @@ "testing", "web" ], - "time": "2015-02-04 17:02:06" + "time": "2015-09-20 20:24:03" }, { "name": "behat/mink-zombie-driver", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/minkphp/MinkZombieDriver.git", - "reference": "cf15a3a0cc4865bb55253cd033a03a20cee6d2d1" + "reference": "257a2d46ffdc8cba28d107c2f1368fc1e5637d1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/minkphp/MinkZombieDriver/zipball/cf15a3a0cc4865bb55253cd033a03a20cee6d2d1", - "reference": "cf15a3a0cc4865bb55253cd033a03a20cee6d2d1", + "url": "https://api.github.com/repos/minkphp/MinkZombieDriver/zipball/257a2d46ffdc8cba28d107c2f1368fc1e5637d1b", + "reference": "257a2d46ffdc8cba28d107c2f1368fc1e5637d1b", "shasum": "" }, "require": { - "behat/mink": "~1.6@dev", + "behat/mink": "~1.7@dev", + "ext-sockets": "*", "php": ">=5.3.1", "symfony/process": "~2.1" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "mink-driver", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { - "psr-0": { - "Behat\\Mink\\Driver": "src/" + "psr-4": { + "Behat\\Mink\\Driver\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1236,7 +1243,7 @@ "testing", "zombie" ], - "time": "2014-09-26 12:26:25" + "time": "2015-09-21 21:07:53" }, { "name": "symfony/css-selector", diff --git a/vendor/behat/mink-zombie-driver/.travis.yml b/vendor/behat/mink-zombie-driver/.travis.yml index 2eae42a3834..82bcb688489 100644 --- a/vendor/behat/mink-zombie-driver/.travis.yml +++ b/vendor/behat/mink-zombie-driver/.travis.yml @@ -1,25 +1,45 @@ language: php -php: [5.3, 5.4, 5.5, 5.6, hhvm] +sudo: false + +cache: + directories: + - $HOME/.composer/cache/files + +php: [5.3, 5.4, 5.5, 5.6, 7, hhvm] + +env: + global: + - IOJS_VERSION='' + - ZOMBIE_VERSION='@^3.0' # npm will install Zombie 4.x by default, even though it is not compatible with node... + - WEB_FIXTURES_HOST=http://localhost:8000 + +matrix: + include: + - php: 5.6 + env: ZOMBIE_VERSION='@^2.0' + - php: 5.6 + env: + - IOJS_VERSION='2.3.1' + - ZOMBIE_VERSION='@^4.0' + allow_failures: + - php: 7 before_script: - - export WEB_FIXTURES_HOST=http://localhost - # Install deps - - composer install --dev --prefer-source + - composer install + + # Start a webserver for web fixtures. Force using PHP 5.6 to be able to run it on PHP 5.3 and HHVM jobs too + - ~/.phpenv/versions/5.6/bin/php -S 127.0.0.1:8000 -t vendor/behat/mink/driver-testsuite/web-fixtures > /dev/null 2>&1 & - - sudo apt-get update > /dev/null - - sudo apt-get install -y --force-yes apache2 libapache2-mod-php5 - - sudo sed -i -e "s,/var/www,$(pwd)/vendor/behat/mink/driver-testsuite/web-fixtures,g" /etc/apache2/sites-available/default - - sudo /etc/init.d/apache2 restart + - npm install zombie$ZOMBIE_VERSION - - npm install zombie + - export NODE_MODULES_PATH="$(pwd)/node_modules/" - - export NODE_PATH="$(pwd)/node_modules" - - export PATH="/usr/local/share/npm/bin:$PATH" + - if [[ "$IOJS_VERSION" != "" ]]; then wget https://iojs.org/dist/v${IOJS_VERSION}/iojs-v${IOJS_VERSION}-linux-x64.tar.xz && tar xf iojs-v${IOJS_VERSION}-linux-x64.tar.xz && export NODE_BIN="`pwd`/iojs-v${IOJS_VERSION}-linux-x64/bin/node"; fi script: phpunit -v --coverage-clover=coverage.clover after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover + # XDebug is not yet available on PHP 7 so we don't have code coverage there. Not uploading it avoids telling Scrutinizer that it is missing + - if [[ "$TRAVIS_PHP_VERSION" != "7" ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/vendor/behat/mink-zombie-driver/CHANGELOG.md b/vendor/behat/mink-zombie-driver/CHANGELOG.md index a3981779ac6..7ec5978e54d 100644 --- a/vendor/behat/mink-zombie-driver/CHANGELOG.md +++ b/vendor/behat/mink-zombie-driver/CHANGELOG.md @@ -1,3 +1,26 @@ +1.3.0 / 2015-09-21 +================== + +New features: + +* Updated the driver to use findElementsXpaths for Mink 1.7 and forward compatibility with Mink 2 + +Bug fixes: + +* Added a dependency on PHP's sockets extension +* Upgrade the authentication logic for Zombie 3 +* Fixed header retrieval for Zombie 4.x+ versions +* Updated `triggerBrowserEvent` to include any output from `evalJs` in the exception message + +Testsuite: + +* Add testing on PHP 7 +* Add testing for Zombie 4.x using IO.JS + +Misc: + +* Updated the repository structure to PSR-4 + 1.2.0 / 2014-09-26 ================== diff --git a/vendor/behat/mink-zombie-driver/README.md b/vendor/behat/mink-zombie-driver/README.md old mode 100755 new mode 100644 index 74f125bda20..491fb067038 --- a/vendor/behat/mink-zombie-driver/README.md +++ b/vendor/behat/mink-zombie-driver/README.md @@ -4,9 +4,9 @@ Mink Zombie.js Driver [](https://packagist.org/packages/behat/mink-zombie-driver) [](https://packagist.org/packages/behat/mink-zombie-driver) [](https://packagist.org/packages/behat/mink-zombie-driver) -[](https://travis-ci.org/Behat/MinkZombieDriver) -[](https://scrutinizer-ci.com/g/Behat/MinkZombieDriver/) -[](https://scrutinizer-ci.com/g/Behat/MinkZombieDriver/) +[](https://travis-ci.org/minkphp/MinkZombieDriver) +[](https://scrutinizer-ci.com/g/minkphp/MinkZombieDriver/) +[](https://scrutinizer-ci.com/g/minkphp/MinkZombieDriver/) [](https://packagist.org/packages/behat/mink-zombie-driver) Installation & Compatibility @@ -17,25 +17,15 @@ You need a working installation of [NodeJS](http://nodejs.org/) and [zombie.js](http://zombie.labnotes.org) library through npm: ``` bash -npm install -g zombie +$ npm install -g zombie ``` The driver requires zombie.js __version 2.0.0 or higher__. Use [Composer](https://getcomposer.org/) to install all required PHP dependencies: -```json -{ - "require": { - "behat/mink": "~1.6", - "behat/mink-zombie-driver": "~1.2" - } -} -``` - ```bash -$> curl -sS https://getcomposer.org/installer | php -$> php composer.phar install +$ composer require --dev behat/mink behat/mink-zombie-driver ``` Usage Example diff --git a/vendor/behat/mink-zombie-driver/composer.json b/vendor/behat/mink-zombie-driver/composer.json index 172c8c1f88b..0c8c63f8f75 100644 --- a/vendor/behat/mink-zombie-driver/composer.json +++ b/vendor/behat/mink-zombie-driver/composer.json @@ -20,14 +20,19 @@ ], "require": { + "ext-sockets": "*", "php": ">=5.3.1", - "behat/mink": "~1.6@dev", + "behat/mink": "~1.7@dev", "symfony/process": "~2.1" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "autoload": { - "psr-0": { - "Behat\\Mink\\Driver": "src/" + "psr-4": { + "Behat\\Mink\\Driver\\": "src/" } }, @@ -39,7 +44,7 @@ "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } } } diff --git a/vendor/behat/mink-zombie-driver/phpunit.xml.dist b/vendor/behat/mink-zombie-driver/phpunit.xml.dist index cd5862fbeab..14a15b8b1c2 100644 --- a/vendor/behat/mink-zombie-driver/phpunit.xml.dist +++ b/vendor/behat/mink-zombie-driver/phpunit.xml.dist @@ -13,11 +13,12 @@ <!--server name="WEB_FIXTURES_HOST" value="http://test.mink.dev" /--> <!--server name="NODE_MODULES_PATH" value="path/to/ZombieDriver/node_modules/" /--> + <!--server name="NODE_BIN" value="node" /--> </php> <filter> <whitelist> - <directory>./src/Behat/Mink/Driver</directory> + <directory>./src</directory> </whitelist> </filter> </phpunit> diff --git a/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Connection.php b/vendor/behat/mink-zombie-driver/src/NodeJS/Connection.php similarity index 100% rename from vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Connection.php rename to vendor/behat/mink-zombie-driver/src/NodeJS/Connection.php diff --git a/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php b/vendor/behat/mink-zombie-driver/src/NodeJS/Server.php similarity index 100% rename from vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php rename to vendor/behat/mink-zombie-driver/src/NodeJS/Server.php diff --git a/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server/ZombieServer.php b/vendor/behat/mink-zombie-driver/src/NodeJS/Server/ZombieServer.php similarity index 100% rename from vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server/ZombieServer.php rename to vendor/behat/mink-zombie-driver/src/NodeJS/Server/ZombieServer.php diff --git a/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/ZombieDriver.php b/vendor/behat/mink-zombie-driver/src/ZombieDriver.php similarity index 95% rename from vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/ZombieDriver.php rename to vendor/behat/mink-zombie-driver/src/ZombieDriver.php index 84a1742dec3..0d47ae01a35 100644 --- a/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/ZombieDriver.php +++ b/vendor/behat/mink-zombie-driver/src/ZombieDriver.php @@ -11,9 +11,7 @@ namespace Behat\Mink\Driver; use Behat\Mink\Driver\NodeJS\Server\ZombieServer; -use Behat\Mink\Element\NodeElement; use Behat\Mink\Exception\DriverException; -use Behat\Mink\Session; /** * Zombie (JS) driver. @@ -22,10 +20,6 @@ use Behat\Mink\Session; */ class ZombieDriver extends CoreDriver { - /** - * @var Session - */ - private $session; private $started = false; private $nativeRefs = array(); private $server = null; @@ -61,14 +55,6 @@ class ZombieDriver extends CoreDriver return $this->server; } - /** - * {@inheritdoc} - */ - public function setSession(Session $session) - { - $this->session = $session; - } - /** * {@inheritdoc} */ @@ -178,15 +164,33 @@ JS; public function setBasicAuth($user, $password) { if (false === $user) { - $this->server->evalJS("browser.authenticate().reset();stream.end();"); - - return; + $user = null; + $password = null; } $userEscaped = json_encode($user); $passwordEscaped = json_encode($password); - $this->server->evalJS("browser.authenticate().basic({$userEscaped}, {$passwordEscaped});stream.end();"); + $js = <<<JS +var username = $userEscaped; +var password = $passwordEscaped; + +if (browser.authenticate) { + if (null === username) { + browser.authenticate().reset(); + } else { + browser.authenticate().basic(username, password); + } +} else { + browser.on('authenticate', function (authentication) { + authentication.username = username; + authentication.password = password; + }); +} +stream.end(); +JS; + + $this->server->evalJS($js); } /** @@ -232,7 +236,14 @@ JS; */ public function getResponseHeaders() { - return (array) $this->server->evalJS('browser.window._response.headers', 'json'); + $js = <<<JS +var response = browser.response || browser.window._response, + headers = response.headers.toObject ? response.headers.toObject() : response.headers; + +stream.end(JSON.stringify(headers)); +JS; + + return json_decode($this->server->evalJS($js), true); } /** @@ -317,7 +328,7 @@ JS; /** * {@inheritdoc} */ - public function find($xpath) + public function findElementXpaths($xpath) { $xpathEncoded = json_encode($xpath); $js = <<<JS @@ -344,7 +355,7 @@ JS; foreach ($refs as $i => $ref) { $subXpath = sprintf('(%s)[%d]', $xpath, $i + 1); $this->nativeRefs[md5($subXpath)] = $ref; - $elements[] = new NodeElement($subXpath, $this->session); + $elements[] = $subXpath; // first node ref also matches the original xpath if (0 === $i) { @@ -858,7 +869,7 @@ browser.fire({$ref}, "{$event}", function (err) { JS; $out = $this->server->evalJS($js); if (!empty($out)) { - throw new DriverException(sprintf("Error while processing event '%s'", $event)); + throw new DriverException(sprintf("Error while processing event '%s': %s", $event, $out)); } } diff --git a/vendor/behat/mink-zombie-driver/tests/ZombieConfig.php b/vendor/behat/mink-zombie-driver/tests/ZombieConfig.php index fad98e4bbe0..94f3c63fe2a 100644 --- a/vendor/behat/mink-zombie-driver/tests/ZombieConfig.php +++ b/vendor/behat/mink-zombie-driver/tests/ZombieConfig.php @@ -17,7 +17,8 @@ class ZombieConfig extends AbstractConfig */ public function createDriver() { - $server = new ZombieServer('127.0.0.1', 8124, 'node'); + $nodeBinary = isset($_SERVER['NODE_BIN']) ? $_SERVER['NODE_BIN'] : 'node'; + $server = new ZombieServer('127.0.0.1', 8124, $nodeBinary); if (isset($_SERVER['NODE_MODULES_PATH'])) { $server->setNodeModulesPath($_SERVER['NODE_MODULES_PATH']); diff --git a/vendor/behat/mink/.travis.yml b/vendor/behat/mink/.travis.yml index 4c0c786d404..677ee0ecfd4 100644 --- a/vendor/behat/mink/.travis.yml +++ b/vendor/behat/mink/.travis.yml @@ -2,16 +2,27 @@ language: php sudo: false -php: [5.3, 5.4, 5.5, 5.6, hhvm] +php: [5.3, 5.4, 5.5, 5.6, 7.0, hhvm] + +matrix: + fast_finish: true + include: + - php: 5.3 + env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable' SYMFONY_DEPRECATIONS_HELPER=weak + allow_failures: + - php: 7.0 cache: directories: - - $HOME/.composer/cache + - $HOME/.composer/cache/files + +before_install: + - composer self-update install: - - composer install + - composer update $COMPOSER_FLAGS script: phpunit -v --coverage-clover=coverage.clover after_script: - - wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover + - if [[ "7.0" != "$TRAVIS_PHP_VERSION" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/vendor/behat/mink/CHANGES.md b/vendor/behat/mink/CHANGES.md index e21d5aff6f4..4ef4ecb28fe 100644 --- a/vendor/behat/mink/CHANGES.md +++ b/vendor/behat/mink/CHANGES.md @@ -1,3 +1,45 @@ +1.7.0 / 2015-09-20 +================== + +New features: + +* Added `Session::getResponseHeader` to access a response header easily +* Added support for header assertions +* Added a forward compatibility layer for drivers to allow them to prepare + for Mink 2.0 (they won't require any change if they use it). They should + now overwrite `CoreDriver::findElementXpaths` instead of implementing `find` + and `setSession` themselves. +* Added escaping of the locator in the NamedSelector rather than expecting + the caller to perform the escaping. Passing an escaped locator is still + supported but deprecated. +* Remove the dependency on the Session in expectation exceptions. Passing + the session in the exception constructor is now deprecated. The driver + should be passed instead. + +Bug fixes: + +* Fixed the URL assertions when comparing paths ending in ``.php`` +* Silenced deprecation warnings (following the Symfony convention) to make + them less invasive. Use the `symfony/phpunit-bridge` to get them reported + when using Mink in your PHPUnit tests. +* Fixed `NodeElement::hasClass` in case the class attribute contains newlines + +Testsuite: + +* Made the testsuite compatible with PHPUnit strict timing mode (only the library testsuite, not the driver one) +* Added testing against PHP 7 +* Added testing against lowest version of dependencies to ensure we got the lower bounds right + +Driver testsuite: + +* Added an extra test to ensure the right behavior when getting the HTML with empty elements +* Added a few more safeguards to ensure test failures rather than fatal errors for misbehaving drivers +* Added a test ensuring that drivers follow recommended practices + +Misc: + +* Added a few missing deprecation warnings for deprecated APIs or classes. + 1.6.1 / 2015-02-04 ================== diff --git a/vendor/behat/mink/LICENSE b/vendor/behat/mink/LICENSE index 14f15e8b483..854754b796c 100644 --- a/vendor/behat/mink/LICENSE +++ b/vendor/behat/mink/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2013 Konstantin Kudryashov <ever.zet@gmail.com> +Copyright (c) 2011-2015 Konstantin Kudryashov <ever.zet@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/vendor/behat/mink/composer.json b/vendor/behat/mink/composer.json index 7a8723f0722..0193f434fa1 100644 --- a/vendor/behat/mink/composer.json +++ b/vendor/behat/mink/composer.json @@ -16,7 +16,11 @@ "require": { "php": ">=5.3.1", - "symfony/css-selector": "~2.0" + "symfony/css-selector": "~2.1" + }, + + "require-dev": { + "symfony/phpunit-bridge": "~2.7" }, "suggest": { @@ -40,7 +44,7 @@ "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } } } diff --git a/vendor/behat/mink/driver-testsuite/tests/AbstractConfig.php b/vendor/behat/mink/driver-testsuite/tests/AbstractConfig.php index f654297561f..057e6fd481a 100644 --- a/vendor/behat/mink/driver-testsuite/tests/AbstractConfig.php +++ b/vendor/behat/mink/driver-testsuite/tests/AbstractConfig.php @@ -33,7 +33,7 @@ abstract class AbstractConfig } /** - * Gets the base url to the fixture folder + * Gets the base url to the fixture folder. * * @return string */ diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/BestPracticesTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/BestPracticesTest.php new file mode 100644 index 00000000000..d6cda7db6aa --- /dev/null +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/BestPracticesTest.php @@ -0,0 +1,84 @@ +<?php + +namespace Behat\Mink\Tests\Driver\Basic; + +use Behat\Mink\Tests\Driver\TestCase; + +/** + * This testcase ensures that the driver implementation follows recommended practices for drivers. + */ +class BestPracticesTest extends TestCase +{ + public function testExtendsCoreDriver() + { + $driver = $this->createDriver(); + + $this->assertInstanceOf('Behat\Mink\Driver\CoreDriver', $driver); + + return $driver; + } + + /** + * @depends testExtendsCoreDriver + */ + public function testImplementFindXpath() + { + $driver = $this->createDriver(); + + $this->assertNotImplementMethod('find', $driver, 'The driver should overwrite `findElementXpaths` rather than `find` for forward compatibility with Mink 2.'); + $this->assertImplementMethod('findElementXpaths', $driver, 'The driver must be able to find elements.'); + $this->assertNotImplementMethod('setSession', $driver, 'The driver should not deal with the Session directly for forward compatibility with Mink 2.'); + } + + /** + * @dataProvider provideRequiredMethods + */ + public function testImplementBasicApi($method) + { + $driver = $this->createDriver(); + + $this->assertImplementMethod($method, $driver, 'The driver is unusable when this method is not implemented.'); + } + + public function provideRequiredMethods() + { + return array( + array('start'), + array('isStarted'), + array('stop'), + array('reset'), + array('visit'), + array('getCurrentUrl'), + array('getContent'), + array('click'), + ); + } + + private function assertImplementMethod($method, $object, $reason = '') + { + $ref = new \ReflectionClass(get_class($object)); + $refMethod = $ref->getMethod($method); + + $message = sprintf('The driver should implement the `%s` method.', $method); + + if ('' !== $reason) { + $message .= ' '.$reason; + } + + $this->assertSame($ref->name, $refMethod->getDeclaringClass()->name, $message); + } + + private function assertNotImplementMethod($method, $object, $reason = '') + { + $ref = new \ReflectionClass(get_class($object)); + $refMethod = $ref->getMethod($method); + + $message = sprintf('The driver should not implement the `%s` method.', $method); + + if ('' !== $reason) { + $message .= ' '.$reason; + } + + $this->assertNotSame($ref->name, $refMethod->getDeclaringClass()->name, $message); + } +} diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/ContentTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/ContentTest.php index 6f516e814ae..fdd0ffacd26 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Basic/ContentTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/ContentTest.php @@ -21,6 +21,18 @@ class ContentTest extends TestCase ); } + public function testDumpingEmptyElements() + { + $this->getSession()->visit($this->pathTo('/index.html')); + + $element = $this->getAssertSession()->elementExists('css', '#empty'); + + $this->assertEquals( + 'An empty <em></em> tag should be rendered with both open and close tags.', + trim($element->getHtml()) + ); + } + /** * @dataProvider getAttributeDataProvider */ diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/CookieTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/CookieTest.php index 355dd717af3..5636c1194ea 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Basic/CookieTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/CookieTest.php @@ -7,7 +7,8 @@ use Behat\Mink\Tests\Driver\TestCase; class CookieTest extends TestCase { /** - * test cookie decoding + * test cookie decoding. + * * @group issue140 */ public function testIssue140() diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/ErrorHandlingTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/ErrorHandlingTest.php index 440585ac12d..bb4bb2dbee4 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Basic/ErrorHandlingTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/ErrorHandlingTest.php @@ -4,6 +4,9 @@ namespace Behat\Mink\Tests\Driver\Basic; use Behat\Mink\Tests\Driver\TestCase; +/** + * @group slow + */ class ErrorHandlingTest extends TestCase { const NOT_FOUND_XPATH = '//html/./invalid'; diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/HeaderTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/HeaderTest.php index 0288ff14ac0..072ceb4180d 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Basic/HeaderTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/HeaderTest.php @@ -7,7 +7,8 @@ use Behat\Mink\Tests\Driver\TestCase; class HeaderTest extends TestCase { /** - * test referrer + * test referrer. + * * @group issue130 */ public function testIssue130() diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/NavigationTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/NavigationTest.php index 8ecb1395a4b..7056316a4a8 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Basic/NavigationTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/NavigationTest.php @@ -12,13 +12,13 @@ class NavigationTest extends TestCase $this->assertEquals($this->pathTo('/redirect_destination.html'), $this->getSession()->getCurrentUrl()); } - public function testPageControlls() + public function testPageControls() { $this->getSession()->visit($this->pathTo('/randomizer.php')); - $number1 = $this->getSession()->getPage()->find('css', '#number')->getText(); + $number1 = $this->getAssertSession()->elementExists('css', '#number')->getText(); $this->getSession()->reload(); - $number2 = $this->getSession()->getPage()->find('css', '#number')->getText(); + $number2 = $this->getAssertSession()->elementExists('css', '#number')->getText(); $this->assertNotEquals($number1, $number2); @@ -58,7 +58,7 @@ class NavigationTest extends TestCase $this->getSession()->visit($this->pathTo('/links.html')); $page = $this->getSession()->getPage(); - $link = $page->findLink("Link with a "); + $link = $page->findLink('Link with a '); $this->assertNotNull($link); $this->assertRegExp('/links\.html\?quoted$/', $link->getAttribute('href')); diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/TraversingTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/TraversingTest.php index 3bcb7ac01a6..6f1ebcbca15 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Basic/TraversingTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/TraversingTest.php @@ -7,7 +7,8 @@ use Behat\Mink\Tests\Driver\TestCase; class TraversingTest extends TestCase { /** - * find by label + * find by label. + * * @group issue211 */ public function testIssue211() @@ -24,20 +25,23 @@ class TraversingTest extends TestCase $page = $this->getSession()->getPage(); - $this->assertNotNull($page->find('css', 'h1')); - $this->assertEquals('Extremely useless page', $page->find('css', 'h1')->getText()); - $this->assertEquals('h1', $page->find('css', 'h1')->getTagName()); + $title = $page->find('css', 'h1'); + $this->assertNotNull($title); + $this->assertEquals('Extremely useless page', $title->getText()); + $this->assertEquals('h1', $title->getTagName()); - $this->assertNotNull($page->find('xpath', '//div/strong[3]')); - $this->assertEquals('pariatur', $page->find('xpath', '//div/strong[3]')->getText()); - $this->assertEquals('super-duper', $page->find('xpath', '//div/strong[3]')->getAttribute('class')); - $this->assertTrue($page->find('xpath', '//div/strong[3]')->hasAttribute('class')); + $strong = $page->find('xpath', '//div/strong[3]'); + $this->assertNotNull($strong); + $this->assertEquals('pariatur', $strong->getText()); + $this->assertEquals('super-duper', $strong->getAttribute('class')); + $this->assertTrue($strong->hasAttribute('class')); - $this->assertNotNull($page->find('xpath', '//div/strong[2]')); - $this->assertEquals('veniam', $page->find('xpath', '//div/strong[2]')->getText()); - $this->assertEquals('strong', $page->find('xpath', '//div/strong[2]')->getTagName()); - $this->assertNull($page->find('xpath', '//div/strong[2]')->getAttribute('class')); - $this->assertFalse($page->find('xpath', '//div/strong[2]')->hasAttribute('class')); + $strong2 = $page->find('xpath', '//div/strong[2]'); + $this->assertNotNull($strong2); + $this->assertEquals('veniam', $strong2->getText()); + $this->assertEquals('strong', $strong2->getTagName()); + $this->assertNull($strong2->getAttribute('class')); + $this->assertFalse($strong2->hasAttribute('class')); $strongs = $page->findAll('css', 'div#core > strong'); $this->assertCount(3, $strongs); @@ -46,6 +50,7 @@ class TraversingTest extends TestCase $element = $page->find('css', '#some-element'); + $this->assertNotNull($element); $this->assertEquals('some very interesting text', $element->getText()); $this->assertEquals( "\n some <div>very\n </div>\n". @@ -105,12 +110,11 @@ class TraversingTest extends TestCase { $this->getSession()->visit($this->pathTo('/index.html')); - $traversDiv = $this->getSession()->getPage()->findAll('css', 'div.travers'); + $traversDivs = $this->getSession()->getPage()->findAll('css', 'div.travers'); - $this->assertCount(1, $traversDiv); - $traversDiv = $traversDiv[0]; + $this->assertCount(1, $traversDivs); - $subDivs = $traversDiv->findAll('css', 'div.sub'); + $subDivs = $traversDivs[0]->findAll('css', 'div.sub'); $this->assertCount(3, $subDivs); $this->assertTrue($subDivs[2]->hasLink('some deep url')); diff --git a/vendor/behat/mink/driver-testsuite/tests/Basic/VisibilityTest.php b/vendor/behat/mink/driver-testsuite/tests/Basic/VisibilityTest.php index b3daf316a38..bb5634e2e6a 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Basic/VisibilityTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Basic/VisibilityTest.php @@ -11,7 +11,7 @@ class VisibilityTest extends TestCase $this->getSession()->visit($this->pathTo('/js_test.html')); $webAssert = $this->getAssertSession(); - $clicker = $webAssert->elementExists('css', '.elements div#clicker'); + $clicker = $webAssert->elementExists('css', '.elements div#clicker'); $invisible = $webAssert->elementExists('css', '#invisible'); $this->assertFalse($invisible->isVisible()); diff --git a/vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php b/vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php index e1ce4ab16fa..18c4088cdda 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php @@ -53,8 +53,8 @@ class CheckboxTest extends TestCase $this->assertEquals('Multicheckbox Test', $webAssert->elementExists('css', 'h1')->getText()); - $updateMail = $webAssert->elementExists('css', '[name="mail_types[]"][value="update"]'); - $spamMail = $webAssert->elementExists('css', '[name="mail_types[]"][value="spam"]'); + $updateMail = $webAssert->elementExists('css', '[name="mail_types[]"][value="update"]'); + $spamMail = $webAssert->elementExists('css', '[name="mail_types[]"][value="spam"]'); $this->assertEquals('update', $updateMail->getValue()); $this->assertNull($spamMail->getValue()); diff --git a/vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php b/vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php index f15f266e015..0e08d34ebaa 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php @@ -25,8 +25,8 @@ class GeneralTest extends TestCase $page = $this->getSession()->getPage(); $this->assertEquals('Basic Form Page', $webAssert->elementExists('css', 'h1')->getText()); - $firstname = $webAssert->fieldExists('first_name'); - $lastname = $webAssert->fieldExists('lastn'); + $firstname = $webAssert->fieldExists('first_name'); + $lastname = $webAssert->fieldExists('lastn'); $this->assertEquals('Firstname', $firstname->getValue()); $this->assertEquals('Lastname', $lastname->getValue()); @@ -150,15 +150,15 @@ class GeneralTest extends TestCase $page = $this->getSession()->getPage(); $this->assertEquals('ADvanced Form Page', $webAssert->elementExists('css', 'h1')->getText()); - $firstname = $webAssert->fieldExists('first_name'); - $lastname = $webAssert->fieldExists('lastn'); - $email = $webAssert->fieldExists('Your email:'); - $select = $webAssert->fieldExists('select_number'); - $sex = $webAssert->fieldExists('sex'); - $maillist = $webAssert->fieldExists('mail_list'); - $agreement = $webAssert->fieldExists('agreement'); - $notes = $webAssert->fieldExists('notes'); - $about = $webAssert->fieldExists('about'); + $firstname = $webAssert->fieldExists('first_name'); + $lastname = $webAssert->fieldExists('lastn'); + $email = $webAssert->fieldExists('Your email:'); + $select = $webAssert->fieldExists('select_number'); + $sex = $webAssert->fieldExists('sex'); + $maillist = $webAssert->fieldExists('mail_list'); + $agreement = $webAssert->fieldExists('agreement'); + $notes = $webAssert->fieldExists('notes'); + $about = $webAssert->fieldExists('about'); $this->assertEquals('Firstname', $firstname->getValue()); $this->assertEquals('Lastname', $lastname->getValue()); diff --git a/vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php b/vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php index 492625a9566..f06d5f02f71 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php @@ -13,7 +13,7 @@ class SelectTest extends TestCase $page = $this->getSession()->getPage(); $this->assertEquals('Multiselect Test', $webAssert->elementExists('css', 'h1')->getText()); - $select = $webAssert->fieldExists('select_number'); + $select = $webAssert->fieldExists('select_number'); $multiSelect = $webAssert->fieldExists('select_multiple_numbers[]'); $secondMultiSelect = $webAssert->fieldExists('select_multiple_values[]'); @@ -66,8 +66,7 @@ OUT; $session->visit($this->pathTo('/multiselect_form.html')); $select = $webAssert->fieldExists($selectName); - $optionValueEscaped = $session->getSelectorsHandler()->xpathLiteral($optionValue); - $option = $webAssert->elementExists('named', array('option', $optionValueEscaped)); + $option = $webAssert->elementExists('named', array('option', $optionValue)); $this->assertFalse($option->isSelected()); $select->selectOption($optionText); diff --git a/vendor/behat/mink/driver-testsuite/tests/Js/ChangeEventTest.php b/vendor/behat/mink/driver-testsuite/tests/Js/ChangeEventTest.php index d1fd3f16762..4c8a30fcf31 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Js/ChangeEventTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Js/ChangeEventTest.php @@ -4,10 +4,13 @@ namespace Behat\Mink\Tests\Driver\Js; use Behat\Mink\Tests\Driver\TestCase; +/** + * @group slow + */ class ChangeEventTest extends TestCase { /** - * 'change' event should be fired after selecting an <option> in a <select> + * 'change' event should be fired after selecting an <option> in a <select>. * * TODO check whether this test is redundant with other change event tests. */ @@ -19,7 +22,7 @@ class ChangeEventTest extends TestCase $session->getPage()->selectFieldOption('foo_select', 'Option 3'); $session->wait(2000, '$("#output_foo_select").text() != ""'); - $this->assertEquals('onChangeSelect', $session->getPage()->find('css', '#output_foo_select')->getText()); + $this->assertEquals('onChangeSelect', $this->getAssertSession()->elementExists('css', '#output_foo_select')->getText()); } public function testIssue178() diff --git a/vendor/behat/mink/driver-testsuite/tests/Js/EventsTest.php b/vendor/behat/mink/driver-testsuite/tests/Js/EventsTest.php index e49d83715fa..f06999bf41f 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Js/EventsTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Js/EventsTest.php @@ -96,7 +96,7 @@ class EventsTest extends TestCase $input1 = $webAssert->elementExists('css', '.elements input.input.first'); $input2 = $webAssert->elementExists('css', '.elements input.input.second'); $input3 = $webAssert->elementExists('css', '.elements input.input.third'); - $event = $webAssert->elementExists('css', '.elements .text-event'); + $event = $webAssert->elementExists('css', '.elements .text-event'); $input1->keyDown('u', $modifier); $this->assertEquals('key downed:'.$eventProperties, $event->getText()); diff --git a/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptEvaluationTest.php b/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptEvaluationTest.php index 00235d11078..ab6ab27f36d 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptEvaluationTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptEvaluationTest.php @@ -25,11 +25,11 @@ class JavascriptEvaluationTest extends TestCase $waitable->click(); $this->getSession()->wait(3000, '$("#waitable").has("div").length > 0'); - $this->assertEquals('arrived', $this->getSession()->getPage()->find('css', '#waitable > div')->getText()); + $this->assertEquals('arrived', $this->getAssertSession()->elementExists('css', '#waitable > div')->getText()); $waitable->click(); $this->getSession()->wait(3000, 'false'); - $this->assertEquals('timeout', $this->getSession()->getPage()->find('css', '#waitable > div')->getText()); + $this->assertEquals('timeout', $this->getAssertSession()->elementExists('css', '#waitable > div')->getText()); } /** diff --git a/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptTest.php b/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptTest.php index 86cfa65ba67..ea6d77ae7e8 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Js/JavascriptTest.php @@ -27,7 +27,7 @@ class JavascriptTest extends TestCase $droppable = $webAssert->elementExists('css', '#droppable'); $draggable->dragTo($droppable); - $this->assertEquals('Dropped!', $droppable->find('css', 'p')->getText()); + $this->assertEquals('Dropped!', $this->getAssertSession()->elementExists('css', 'p', $droppable)->getText()); } // test accentuated char in button diff --git a/vendor/behat/mink/driver-testsuite/tests/Js/WindowTest.php b/vendor/behat/mink/driver-testsuite/tests/Js/WindowTest.php index 70b9ed96753..ca4949113eb 100644 --- a/vendor/behat/mink/driver-testsuite/tests/Js/WindowTest.php +++ b/vendor/behat/mink/driver-testsuite/tests/Js/WindowTest.php @@ -10,7 +10,7 @@ class WindowTest extends TestCase { $this->getSession()->visit($this->pathTo('/window.html')); $session = $this->getSession(); - $page = $session->getPage(); + $page = $session->getPage(); $webAssert = $this->getAssertSession(); $page->clickLink('Popup #1'); @@ -39,7 +39,7 @@ class WindowTest extends TestCase { $this->getSession()->visit($this->pathTo('/window.html')); $session = $this->getSession(); - $page = $session->getPage(); + $page = $session->getPage(); $windowName = $this->getSession()->getWindowName(); @@ -63,7 +63,7 @@ class WindowTest extends TestCase $session->resizeWindow(400, 300); $session->wait(1000, 'false'); - $script = "return Math.abs(window.outerHeight - 300) <= 100 && Math.abs(window.outerWidth - 400) <= 100;"; + $script = 'return Math.abs(window.outerHeight - 300) <= 100 && Math.abs(window.outerWidth - 400) <= 100;'; $this->assertTrue($session->evaluateScript($script)); } @@ -76,7 +76,7 @@ class WindowTest extends TestCase $session->maximizeWindow(); $session->wait(1000, 'false'); - $script = "return Math.abs(screen.availHeight - window.outerHeight) <= 100;"; + $script = 'return Math.abs(screen.availHeight - window.outerHeight) <= 100;'; $this->assertTrue($session->evaluateScript($script)); } diff --git a/vendor/behat/mink/driver-testsuite/tests/TestCase.php b/vendor/behat/mink/driver-testsuite/tests/TestCase.php index ea003ce5c47..964a71f8786 100644 --- a/vendor/behat/mink/driver-testsuite/tests/TestCase.php +++ b/vendor/behat/mink/driver-testsuite/tests/TestCase.php @@ -22,7 +22,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase private static $config; /** - * Initializes the test case + * Initializes the test case. */ public static function setUpBeforeClass() { @@ -102,11 +102,22 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase */ protected function findById($id) { - $id = $this->getSession()->getSelectorsHandler()->xpathLiteral($id); - return $this->getAssertSession()->elementExists('named', array('id', $id)); } + /** + * Creates a new driver instance. + * + * This driver is not associated to a session. It is meant to be used for tests on the driver + * implementation itself rather than test using the Mink API. + * + * @return \Behat\Mink\Driver\DriverInterface + */ + protected function createDriver() + { + return self::getConfig()->createDriver(); + } + /** * Map remote file path. * @@ -136,7 +147,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase } /** - * Waits for a condition to be true, considering than it is successful for drivers not supporting wait() + * Waits for a condition to be true, considering than it is successful for drivers not supporting wait(). * * @param int $time * @param string $condition A JS condition to evaluate diff --git a/vendor/behat/mink/driver-testsuite/web-fixtures/element_change_detector.html b/vendor/behat/mink/driver-testsuite/web-fixtures/element_change_detector.html index af3032a4610..c309baefadd 100644 --- a/vendor/behat/mink/driver-testsuite/web-fixtures/element_change_detector.html +++ b/vendor/behat/mink/driver-testsuite/web-fixtures/element_change_detector.html @@ -41,7 +41,7 @@ var $change_registry = {}, $results = $('#results'); - $(':input').change(function ($e) { + $(':input').change(function () { var $result_id = this.id + '-result'; if (!$change_registry[this.id]) { diff --git a/vendor/behat/mink/driver-testsuite/web-fixtures/index.html b/vendor/behat/mink/driver-testsuite/web-fixtures/index.html index 6bb379c1285..cc8c821ced1 100644 --- a/vendor/behat/mink/driver-testsuite/web-fixtures/index.html +++ b/vendor/behat/mink/driver-testsuite/web-fixtures/index.html @@ -9,6 +9,10 @@ <div id="core"> <strong>Lorem</strong> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim <strong>veniam</strong>, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla <strong class="super-duper">pariatur</strong>. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <div id="empty"> + An empty <em></em> tag should be rendered with both open and close tags. + </div> + <div id="some-element" data-href="http://mink.behat.org"> some <div>very </div> diff --git a/vendor/behat/mink/driver-testsuite/web-fixtures/issue225.html b/vendor/behat/mink/driver-testsuite/web-fixtures/issue225.html index 2178bba9eac..13214631fab 100644 --- a/vendor/behat/mink/driver-testsuite/web-fixtures/issue225.html +++ b/vendor/behat/mink/driver-testsuite/web-fixtures/issue225.html @@ -12,7 +12,7 @@ <div id="panel"></div> <script type="text/javascript"> - $('#btn').click(function (event) { + $('#btn').click(function () { $('#panel').text('OH ' + 'AIH!'); }); </script> diff --git a/vendor/behat/mink/driver-testsuite/web-fixtures/js_test.html b/vendor/behat/mink/driver-testsuite/web-fixtures/js_test.html index e965a40881e..6285455e9d0 100644 --- a/vendor/behat/mink/driver-testsuite/web-fixtures/js_test.html +++ b/vendor/behat/mink/driver-testsuite/web-fixtures/js_test.html @@ -44,23 +44,27 @@ <script src="js/jquery-ui-1.8.14.custom.min.js"></script> <script> $(document).ready(function() { - $('#clicker').click(function() { + var $clicker = $('#clicker'); + + $clicker.click(function() { $(this).text('single clicked'); }); - $('#clicker').dblclick(function() { + $clicker.dblclick(function() { $(this).text('double clicked'); }); - $('#clicker').bind('contextmenu', function() { + $clicker.bind('contextmenu', function() { $(this).text('right clicked'); }); - $('#focus-blur-detector').focus(function() { + var $focusDetector = $('#focus-blur-detector'); + + $focusDetector.focus(function() { $(this).val('focused'); }); - $('#focus-blur-detector').blur(function() { + $focusDetector.blur(function() { $(this).val('blured'); }); diff --git a/vendor/behat/mink/src/Driver/CoreDriver.php b/vendor/behat/mink/src/Driver/CoreDriver.php index 248f291ea68..9b4c04e4320 100644 --- a/vendor/behat/mink/src/Driver/CoreDriver.php +++ b/vendor/behat/mink/src/Driver/CoreDriver.php @@ -10,6 +10,7 @@ namespace Behat\Mink\Driver; +use Behat\Mink\Element\NodeElement; use Behat\Mink\Exception\UnsupportedDriverActionException; use Behat\Mink\Session; @@ -21,12 +22,17 @@ use Behat\Mink\Session; */ abstract class CoreDriver implements DriverInterface { + /** + * @var Session + */ + private $session; + /** * {@inheritdoc} */ public function setSession(Session $session) { - throw new UnsupportedDriverActionException('Setting the session is not supported by %s', $this); + $this->session = $session; } /** @@ -89,6 +95,28 @@ abstract class CoreDriver implements DriverInterface * {@inheritdoc} */ public function find($xpath) + { + $elements = array(); + + foreach ($this->findElementXpaths($xpath) as $xpath) { + $elements[] = new NodeElement($xpath, $this->session); + } + + return $elements; + } + + /** + * Finds elements with specified XPath query. + * + * @see find() + * + * @param string $xpath + * + * @return string[] The XPath of the matched elements + * + * @throws UnsupportedDriverActionException When operation not supported by the driver + */ + protected function findElementXpaths($xpath) { throw new UnsupportedDriverActionException('Finding elements is not supported by %s', $this); } diff --git a/vendor/behat/mink/src/Driver/DriverInterface.php b/vendor/behat/mink/src/Driver/DriverInterface.php index 8357caa8b90..0880960c779 100644 --- a/vendor/behat/mink/src/Driver/DriverInterface.php +++ b/vendor/behat/mink/src/Driver/DriverInterface.php @@ -140,7 +140,7 @@ interface DriverInterface public function back(); /** - * Sets HTTP Basic authentication parameters + * Sets HTTP Basic authentication parameters. * * @param string|Boolean $user user name or false to disable authentication * @param string $password password @@ -217,7 +217,7 @@ interface DriverInterface /** * Returns last response status code. * - * @return integer + * @return int * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done @@ -519,9 +519,9 @@ interface DriverInterface /** * Presses specific keyboard key. * - * @param string $xpath - * @param string|integer $char could be either char ('b') or char-code (98) - * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * @param string $xpath + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done @@ -531,9 +531,9 @@ interface DriverInterface /** * Pressed down specific keyboard key. * - * @param string $xpath - * @param string|integer $char could be either char ('b') or char-code (98) - * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * @param string $xpath + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done @@ -543,9 +543,9 @@ interface DriverInterface /** * Pressed up specific keyboard key. * - * @param string $xpath - * @param string|integer $char could be either char ('b') or char-code (98) - * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * @param string $xpath + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done @@ -591,10 +591,10 @@ interface DriverInterface /** * Waits some time or until JS condition turns true. * - * @param integer $timeout timeout in milliseconds - * @param string $condition JS condition + * @param int $timeout timeout in milliseconds + * @param string $condition JS condition * - * @return boolean + * @return bool * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done @@ -604,9 +604,9 @@ interface DriverInterface /** * Set the dimensions of the window. * - * @param integer $width set the window width, measured in pixels - * @param integer $height set the window height, measured in pixels - * @param string $name window name (null for the main window) + * @param int $width set the window width, measured in pixels + * @param int $height set the window height, measured in pixels + * @param string $name window name (null for the main window) * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done @@ -614,7 +614,7 @@ interface DriverInterface public function resizeWindow($width, $height, $name = null); /** - * Maximize the window if it is not maximized already + * Maximizes the window if it is not maximized already. * * @param string $name window name (null for the main window) * diff --git a/vendor/behat/mink/src/Element/DocumentElement.php b/vendor/behat/mink/src/Element/DocumentElement.php index edde3c35392..c2daf6601fe 100644 --- a/vendor/behat/mink/src/Element/DocumentElement.php +++ b/vendor/behat/mink/src/Element/DocumentElement.php @@ -46,8 +46,6 @@ class DocumentElement extends TraversableElement */ public function hasContent($content) { - return $this->has('named', array( - 'content', $this->getSelectorsHandler()->xpathLiteral($content), - )); + return $this->has('named', array('content', $content)); } } diff --git a/vendor/behat/mink/src/Element/Element.php b/vendor/behat/mink/src/Element/Element.php index 07e1e119efd..a2b6c0ef33f 100644 --- a/vendor/behat/mink/src/Element/Element.php +++ b/vendor/behat/mink/src/Element/Element.php @@ -68,6 +68,8 @@ abstract class Element implements ElementInterface */ public function getSession() { + @trigger_error(sprintf('The method %s is deprecated as of 1.6 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED); + return $this->session; } @@ -85,9 +87,13 @@ abstract class Element implements ElementInterface * Returns selectors handler. * * @return SelectorsHandler + * + * @deprecated Accessing the selectors handler in the element is deprecated as of 1.7 and will be impossible in 2.0. */ protected function getSelectorsHandler() { + @trigger_error(sprintf('The method %s is deprecated as of 1.7 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED); + return $this->selectorsHandler; } @@ -156,7 +162,7 @@ abstract class Element implements ElementInterface return $items; } - $xpath = $this->getSelectorsHandler()->selectorToXpath($selector, $locator); + $xpath = $this->selectorsHandler->selectorToXpath($selector, $locator); $xpath = $this->xpathManipulator->prepend($xpath, $this->getXpath()); return $this->getDriver()->find($xpath); @@ -189,19 +195,20 @@ abstract class Element implements ElementInterface } /** - * Builds an ElementNotFoundException - * - * This is an helper to build the ElementNotFoundException without - * needing to use the deprecated getSession accessor in child classes. + * Builds an ElementNotFoundException. * * @param string $type * @param string|null $selector * @param string|null $locator * * @return ElementNotFoundException + * + * @deprecated as of 1.7, to be removed in 2.0 */ protected function elementNotFound($type, $selector = null, $locator = null) { - return new ElementNotFoundException($this->session, $type, $selector, $locator); + @trigger_error(sprintf('The method %s is deprecated as of 1.7 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED); + + return new ElementNotFoundException($this->driver, $type, $selector, $locator); } } diff --git a/vendor/behat/mink/src/Element/ElementInterface.php b/vendor/behat/mink/src/Element/ElementInterface.php index 8c134b96fcd..1d9cc4f9ec0 100644 --- a/vendor/behat/mink/src/Element/ElementInterface.php +++ b/vendor/behat/mink/src/Element/ElementInterface.php @@ -50,7 +50,7 @@ interface ElementInterface /** * Checks if an element still exists in the DOM. * - * @return boolean + * @return bool */ public function isValid(); @@ -62,6 +62,7 @@ interface ElementInterface * Will receive reference to `this element` as first argument. * * @return mixed + * * @throws \InvalidArgumentException When invalid callback given. */ public function waitFor($timeout, $callback); diff --git a/vendor/behat/mink/src/Element/NodeElement.php b/vendor/behat/mink/src/Element/NodeElement.php index 8e43546267a..bbb857332ca 100644 --- a/vendor/behat/mink/src/Element/NodeElement.php +++ b/vendor/behat/mink/src/Element/NodeElement.php @@ -130,16 +130,16 @@ class NodeElement extends TraversableElement } /** - * Checks whether an element has a named CSS class + * Checks whether an element has a named CSS class. * * @param string $className Name of the class * - * @return boolean + * @return bool */ public function hasClass($className) { if ($this->hasAttribute('class')) { - return in_array($className, explode(' ', $this->getAttribute('class'))); + return in_array($className, preg_split('/\s+/', $this->getAttribute('class'))); } return false; @@ -206,7 +206,7 @@ class NodeElement extends TraversableElement } /** - * Selects specified option for select field or specified radio button in the group + * Selects specified option for select field or specified radio button in the group. * * If the current node is a select box, this selects the option found by its value or * its text. @@ -228,12 +228,10 @@ class NodeElement extends TraversableElement return; } - $opt = $this->find('named', array( - 'option', $this->getSelectorsHandler()->xpathLiteral($option), - )); + $opt = $this->find('named', array('option', $option)); if (null === $opt) { - throw $this->elementNotFound('select option', 'value|text', $option); + throw new ElementNotFoundException($this->getDriver(), 'select option', 'value|text', $option); } $this->getDriver()->selectOption($this->getXpath(), $opt->getValue(), $multiple); @@ -310,8 +308,8 @@ class NodeElement extends TraversableElement /** * Presses specific keyboard key. * - * @param string|integer $char could be either char ('b') or char-code (98) - * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') */ public function keyPress($char, $modifier = null) { @@ -321,8 +319,8 @@ class NodeElement extends TraversableElement /** * Pressed down specific keyboard key. * - * @param string|integer $char could be either char ('b') or char-code (98) - * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') */ public function keyDown($char, $modifier = null) { @@ -332,8 +330,8 @@ class NodeElement extends TraversableElement /** * Pressed up specific keyboard key. * - * @param string|integer $char could be either char ('b') or char-code (98) - * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') */ public function keyUp($char, $modifier = null) { diff --git a/vendor/behat/mink/src/Element/TraversableElement.php b/vendor/behat/mink/src/Element/TraversableElement.php index 0621af3e55d..a5e05b9991b 100644 --- a/vendor/behat/mink/src/Element/TraversableElement.php +++ b/vendor/behat/mink/src/Element/TraversableElement.php @@ -28,8 +28,6 @@ abstract class TraversableElement extends Element */ public function findById($id) { - $id = $this->getSelectorsHandler()->xpathLiteral($id); - return $this->find('named', array('id', $id)); } @@ -54,9 +52,7 @@ abstract class TraversableElement extends Element */ public function findLink($locator) { - return $this->find('named', array( - 'link', $this->getSelectorsHandler()->xpathLiteral($locator), - )); + return $this->find('named', array('link', $locator)); } /** @@ -71,7 +67,7 @@ abstract class TraversableElement extends Element $link = $this->findLink($locator); if (null === $link) { - throw $this->elementNotFound('link', 'id|title|alt|text', $locator); + throw new ElementNotFoundException($this->getDriver(), 'link', 'id|title|alt|text', $locator); } $link->click(); @@ -98,9 +94,7 @@ abstract class TraversableElement extends Element */ public function findButton($locator) { - return $this->find('named', array( - 'button', $this->getSelectorsHandler()->xpathLiteral($locator), - )); + return $this->find('named', array('button', $locator)); } /** @@ -115,7 +109,7 @@ abstract class TraversableElement extends Element $button = $this->findButton($locator); if (null === $button) { - throw $this->elementNotFound('button', 'id|name|title|alt|value', $locator); + throw new ElementNotFoundException($this->getDriver(), 'button', 'id|name|title|alt|value', $locator); } $button->press(); @@ -142,9 +136,7 @@ abstract class TraversableElement extends Element */ public function findField($locator) { - return $this->find('named', array( - 'field', $this->getSelectorsHandler()->xpathLiteral($locator), - )); + return $this->find('named', array('field', $locator)); } /** @@ -162,7 +154,7 @@ abstract class TraversableElement extends Element $field = $this->findField($locator); if (null === $field) { - throw $this->elementNotFound('form field', 'id|name|label|value', $locator); + throw new ElementNotFoundException($this->getDriver(), 'form field', 'id|name|label|value|placeholder', $locator); } $field->setValue($value); @@ -212,7 +204,7 @@ abstract class TraversableElement extends Element $field = $this->findField($locator); if (null === $field) { - throw $this->elementNotFound('form field', 'id|name|label|value', $locator); + throw new ElementNotFoundException($this->getDriver(), 'form field', 'id|name|label|value', $locator); } $field->check(); @@ -230,7 +222,7 @@ abstract class TraversableElement extends Element $field = $this->findField($locator); if (null === $field) { - throw $this->elementNotFound('form field', 'id|name|label|value', $locator); + throw new ElementNotFoundException($this->getDriver(), 'form field', 'id|name|label|value', $locator); } $field->uncheck(); @@ -245,9 +237,7 @@ abstract class TraversableElement extends Element */ public function hasSelect($locator) { - return $this->has('named', array( - 'select', $this->getSelectorsHandler()->xpathLiteral($locator), - )); + return $this->has('named', array('select', $locator)); } /** @@ -266,7 +256,7 @@ abstract class TraversableElement extends Element $field = $this->findField($locator); if (null === $field) { - throw $this->elementNotFound('form field', 'id|name|label|value', $locator); + throw new ElementNotFoundException($this->getDriver(), 'form field', 'id|name|label|value', $locator); } $field->selectOption($value, $multiple); @@ -281,9 +271,7 @@ abstract class TraversableElement extends Element */ public function hasTable($locator) { - return $this->has('named', array( - 'table', $this->getSelectorsHandler()->xpathLiteral($locator), - )); + return $this->has('named', array('table', $locator)); } /** @@ -301,7 +289,7 @@ abstract class TraversableElement extends Element $field = $this->findField($locator); if (null === $field) { - throw $this->elementNotFound('form field', 'id|name|label|value', $locator); + throw new ElementNotFoundException($this->getDriver(), 'form field', 'id|name|label|value', $locator); } $field->attachFile($path); diff --git a/vendor/behat/mink/src/Exception/ElementException.php b/vendor/behat/mink/src/Exception/ElementException.php index 49d5c6c9d59..16ebdc9813c 100644 --- a/vendor/behat/mink/src/Exception/ElementException.php +++ b/vendor/behat/mink/src/Exception/ElementException.php @@ -10,10 +10,12 @@ namespace Behat\Mink\Exception; +@trigger_error('The class '.__NAMESPACE__.'\ElementException is deprecated as of Mink 1.6 and will be removed in 2.0', E_USER_DEPRECATED); + use Behat\Mink\Element\Element; /** - * A standard way for elements to re-throw exceptions + * A standard way for elements to re-throw exceptions. * * @deprecated This exception class is not used anymore in Mink 1.6 and will be removed in 2.0 * @@ -47,7 +49,7 @@ class ElementException extends Exception } /** - * Get the element that caused the exception + * Get the element that caused the exception. * * @return Element */ diff --git a/vendor/behat/mink/src/Exception/ElementHtmlException.php b/vendor/behat/mink/src/Exception/ElementHtmlException.php index 99e2ea601da..fb2fed68ef8 100644 --- a/vendor/behat/mink/src/Exception/ElementHtmlException.php +++ b/vendor/behat/mink/src/Exception/ElementHtmlException.php @@ -10,8 +10,9 @@ namespace Behat\Mink\Exception; -use Behat\Mink\Session; +use Behat\Mink\Driver\DriverInterface; use Behat\Mink\Element\Element; +use Behat\Mink\Session; /** * Exception thrown when an expectation on the HTML of an element fails. @@ -30,16 +31,16 @@ class ElementHtmlException extends ExpectationException /** * Initializes exception. * - * @param string $message optional message - * @param Session $session session instance - * @param Element $element element - * @param \Exception $exception expectation exception + * @param string $message optional message + * @param DriverInterface|Session $driver driver instance + * @param Element $element element + * @param \Exception $exception expectation exception */ - public function __construct($message, Session $session, Element $element, \Exception $exception = null) + public function __construct($message, $driver, Element $element, \Exception $exception = null) { $this->element = $element; - parent::__construct($message, $session, $exception); + parent::__construct($message, $driver, $exception); } protected function getContext() diff --git a/vendor/behat/mink/src/Exception/ElementNotFoundException.php b/vendor/behat/mink/src/Exception/ElementNotFoundException.php index 95fd5f0b873..6716ab3ff70 100644 --- a/vendor/behat/mink/src/Exception/ElementNotFoundException.php +++ b/vendor/behat/mink/src/Exception/ElementNotFoundException.php @@ -10,6 +10,7 @@ namespace Behat\Mink\Exception; +use Behat\Mink\Driver\DriverInterface; use Behat\Mink\Session; /** @@ -22,12 +23,12 @@ class ElementNotFoundException extends ExpectationException /** * Initializes exception. * - * @param Session $session session instance - * @param string $type element type - * @param string $selector element selector type - * @param string $locator element locator + * @param DriverInterface|Session $driver driver instance + * @param string $type element type + * @param string $selector element selector type + * @param string $locator element locator */ - public function __construct(Session $session, $type = null, $selector = null, $locator = null) + public function __construct($driver, $type = null, $selector = null, $locator = null) { $message = ''; @@ -48,6 +49,6 @@ class ElementNotFoundException extends ExpectationException $message .= ' not found.'; - parent::__construct($message, $session); + parent::__construct($message, $driver); } } diff --git a/vendor/behat/mink/src/Exception/ExpectationException.php b/vendor/behat/mink/src/Exception/ExpectationException.php index 25034d1e73e..35f7150a298 100644 --- a/vendor/behat/mink/src/Exception/ExpectationException.php +++ b/vendor/behat/mink/src/Exception/ExpectationException.php @@ -10,6 +10,7 @@ namespace Behat\Mink\Exception; +use Behat\Mink\Driver\DriverInterface; use Behat\Mink\Session; /** @@ -22,17 +23,28 @@ use Behat\Mink\Session; class ExpectationException extends Exception { private $session; + private $driver; /** * Initializes exception. * - * @param string $message optional message - * @param Session $session session instance - * @param \Exception $exception expectation exception + * @param string $message optional message + * @param DriverInterface|Session $driver driver instance (or session for BC) + * @param \Exception|null $exception expectation exception */ - public function __construct($message, Session $session, \Exception $exception = null) + public function __construct($message, $driver, \Exception $exception = null) { - $this->session = $session; + if ($driver instanceof Session) { + @trigger_error('Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.', E_USER_DEPRECATED); + + $this->session = $driver; + $this->driver = $driver->getDriver(); + } elseif (!$driver instanceof DriverInterface) { + // Trigger an exception as we cannot typehint a disjunction + throw new \InvalidArgumentException('The ExpectationException constructor expects a DriverInterface or a Session.'); + } else { + $this->driver = $driver; + } if (!$message && null !== $exception) { $message = $exception->getMessage(); @@ -50,7 +62,7 @@ class ExpectationException extends Exception { try { $pageText = $this->pipeString($this->trimString($this->getContext())."\n"); - $string = sprintf("%s\n\n%s%s", $this->getMessage(), $this->getResponseInfo(), $pageText); + $string = sprintf("%s\n\n%s%s", $this->getMessage(), $this->getResponseInfo(), $pageText); } catch (\Exception $e) { return $this->getMessage(); } @@ -59,22 +71,40 @@ class ExpectationException extends Exception } /** - * Gets the context rendered for this exception + * Gets the context rendered for this exception. * * @return string */ protected function getContext() { - return $this->trimBody($this->getSession()->getPage()->getContent()); + return $this->trimBody($this->driver->getContent()); + } + + /** + * Returns driver. + * + * @return DriverInterface + */ + protected function getDriver() + { + return $this->driver; } /** * Returns exception session. * * @return Session + * + * @deprecated since 1.7, to be removed in 2.0. Use getDriver and the driver API instead. */ protected function getSession() { + if (null === $this->session) { + throw new \LogicException(sprintf('The deprecated method %s cannot be used when passing a driver in the constructor', __METHOD__)); + } + + @trigger_error(sprintf('The method %s is deprecated as of Mink 1.7 and will be removed in 2.0. Use getDriver and the driver API instead.')); + return $this->session; } @@ -107,8 +137,8 @@ class ExpectationException extends Exception /** * Trims string to specified number of chars. * - * @param string $string response content - * @param integer $count trim count + * @param string $string response content + * @param int $count trim count * * @return string */ @@ -130,15 +160,15 @@ class ExpectationException extends Exception */ protected function getResponseInfo() { - $driver = basename(str_replace('\\', '/', get_class($this->session->getDriver()))); + $driver = basename(str_replace('\\', '/', get_class($this->driver))); $info = '+--[ '; try { - $info .= 'HTTP/1.1 '.$this->session->getStatusCode().' | '; + $info .= 'HTTP/1.1 '.$this->driver->getStatusCode().' | '; } catch (UnsupportedDriverActionException $e) { // Ignore the status code when not supported } - $info .= $this->session->getCurrentUrl().' | '.$driver." ]\n|\n"; + $info .= $this->driver->getCurrentUrl().' | '.$driver." ]\n|\n"; return $info; } diff --git a/vendor/behat/mink/src/Exception/ResponseTextException.php b/vendor/behat/mink/src/Exception/ResponseTextException.php index 145ed6da05b..515c5694df5 100644 --- a/vendor/behat/mink/src/Exception/ResponseTextException.php +++ b/vendor/behat/mink/src/Exception/ResponseTextException.php @@ -19,6 +19,6 @@ class ResponseTextException extends ExpectationException { protected function getContext() { - return $this->getSession()->getPage()->getText(); + return $this->getDriver()->getText('//html'); } } diff --git a/vendor/behat/mink/src/Mink.php b/vendor/behat/mink/src/Mink.php index d1621b17443..333bfbdecea 100644 --- a/vendor/behat/mink/src/Mink.php +++ b/vendor/behat/mink/src/Mink.php @@ -121,7 +121,7 @@ class Mink } /** - * Checks whether a named session (or the default session) has already been started + * Checks whether a named session (or the default session) has already been started. * * @param string $name session name - if null then the default session will be checked * diff --git a/vendor/behat/mink/src/Selector/NamedSelector.php b/vendor/behat/mink/src/Selector/NamedSelector.php index 4845f994f9e..d1936cc12ed 100644 --- a/vendor/behat/mink/src/Selector/NamedSelector.php +++ b/vendor/behat/mink/src/Selector/NamedSelector.php @@ -10,6 +10,8 @@ namespace Behat\Mink\Selector; +use Behat\Mink\Selector\Xpath\Escaper; + /** * Named selectors engine. Uses registered XPath selectors to create new expressions. * @@ -157,12 +159,15 @@ XPATH .//*[%idOrNameMatch%] XPATH ); + private $xpathEscaper; /** * Creates selector instance. */ public function __construct() { + $this->xpathEscaper = new Escaper(); + foreach ($this->replacements as $from => $to) { $this->replacements[$from] = strtr($to, $this->replacements); } @@ -199,11 +204,11 @@ XPATH } if (2 == count($locator)) { - $selector = $locator[0]; - $locator = $locator[1]; + $selector = $locator[0]; + $locator = $locator[1]; } else { - $selector = (string) $locator; - $locator = null; + $selector = (string) $locator; + $locator = null; } if (!isset($this->selectors[$selector])) { @@ -217,14 +222,14 @@ XPATH $xpath = $this->selectors[$selector]; if (null !== $locator) { - $xpath = strtr($xpath, array('%locator%' => $locator)); + $xpath = strtr($xpath, array('%locator%' => $this->escapeLocator($locator))); } return $xpath; } /** - * Registers a replacement in the list of replacements + * Registers a replacement in the list of replacements. * * This method must be called in the constructor before calling the parent constructor. * @@ -235,4 +240,24 @@ XPATH { $this->replacements[$from] = $to; } + + private function escapeLocator($locator) + { + // If the locator looks like an escaped one, don't escape it again for BC reasons. + if ( + preg_match('/^\'[^\']*+\'$/', $locator) + || (false !== strpos($locator, '\'') && preg_match('/^"[^"]*+"$/', $locator)) + || ((8 < $length = strlen($locator)) && 'concat(' === substr($locator, 0, 7) && ')' === $locator[$length - 1]) + ) { + @trigger_error( + 'Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0.' + .' Pass the raw value instead.', + E_USER_DEPRECATED + ); + + return $locator; + } + + return $this->xpathEscaper->escapeLiteral($locator); + } } diff --git a/vendor/behat/mink/src/Selector/SelectorsHandler.php b/vendor/behat/mink/src/Selector/SelectorsHandler.php index a19de675158..09b947ca5fe 100644 --- a/vendor/behat/mink/src/Selector/SelectorsHandler.php +++ b/vendor/behat/mink/src/Selector/SelectorsHandler.php @@ -75,7 +75,7 @@ class SelectorsHandler public function getSelector($name) { if ('named' === $name) { - trigger_error( + @trigger_error( 'Using the "named" selector directly from the handler is deprecated as of 1.6 and will be removed in 2.0.' .' Use the "named_partial" or use the "named" selector through the Element API instead.', E_USER_DEPRECATED @@ -114,12 +114,22 @@ class SelectorsHandler /** * Translates string to XPath literal. * + * @deprecated since Mink 1.7. Use \Behat\Mink\Selector\Xpath\Escaper::escapeLiteral when building Xpath + * or pass the unescaped value when using the named selector. + * * @param string $s * * @return string */ public function xpathLiteral($s) { + @trigger_error( + 'The '.__METHOD__.' method is deprecated as of 1.7 and will be removed in 2.0.' + .' Use \Behat\Mink\Selector\Xpath\Escaper::escapeLiteral instead when building Xpath' + .' or pass the unescaped value when using the named selector.', + E_USER_DEPRECATED + ); + return $this->escaper->escapeLiteral($s); } } diff --git a/vendor/behat/mink/src/Selector/Xpath/Escaper.php b/vendor/behat/mink/src/Selector/Xpath/Escaper.php index be3500018dc..c3aa7a3bab2 100644 --- a/vendor/behat/mink/src/Selector/Xpath/Escaper.php +++ b/vendor/behat/mink/src/Selector/Xpath/Escaper.php @@ -47,6 +47,6 @@ class Escaper } } - return sprintf("concat(%s)", implode($parts, ',')); + return sprintf('concat(%s)', implode($parts, ',')); } } diff --git a/vendor/behat/mink/src/Session.php b/vendor/behat/mink/src/Session.php index c67f7f9b4e1..c8815f9582a 100644 --- a/vendor/behat/mink/src/Session.php +++ b/vendor/behat/mink/src/Session.php @@ -39,9 +39,9 @@ class Session $selectorsHandler = new SelectorsHandler(); } - $this->driver = $driver; + $this->driver = $driver; $this->selectorsHandler = $selectorsHandler; - $this->page = new DocumentElement($this); + $this->page = new DocumentElement($this); } /** @@ -144,7 +144,7 @@ class Session } /** - * Sets HTTP Basic authentication parameters + * Sets HTTP Basic authentication parameters. * * @param string|Boolean $user user name or false to disable authentication * @param string $password password @@ -175,6 +175,27 @@ class Session return $this->driver->getResponseHeaders(); } + /** + * Returns specific response header. + * + * @param string $name + * + * @return string|null + */ + public function getResponseHeader($name) + { + $headers = $this->driver->getResponseHeaders(); + + $name = strtolower($name); + $headers = array_change_key_case($headers, CASE_LOWER); + + if (!isset($headers[$name])) { + return null; + } + + return is_array($headers[$name]) ? $headers[$name][0] : $headers[$name]; + } + /** * Sets cookie. * @@ -201,7 +222,7 @@ class Session /** * Returns response status code. * - * @return integer + * @return int */ public function getStatusCode() { @@ -230,7 +251,7 @@ class Session } /** - * Return the names of all open windows + * Return the names of all open windows. * * @return array Array of all open window's names. */ @@ -240,7 +261,7 @@ class Session } /** - * Return the name of the currently active window + * Return the name of the currently active window. * * @return string The name of the current window. */ @@ -318,10 +339,10 @@ class Session /** * Waits some time or until JS condition turns true. * - * @param integer $time time in milliseconds - * @param string $condition JS condition + * @param int $time time in milliseconds + * @param string $condition JS condition * - * @return boolean + * @return bool */ public function wait($time, $condition = 'false') { @@ -331,9 +352,9 @@ class Session /** * Set the dimensions of the window. * - * @param integer $width set the window width, measured in pixels - * @param integer $height set the window height, measured in pixels - * @param string $name window name (null for the main window) + * @param int $width set the window width, measured in pixels + * @param int $height set the window height, measured in pixels + * @param string $name window name (null for the main window) */ public function resizeWindow($width, $height, $name = null) { @@ -341,7 +362,7 @@ class Session } /** - * Maximize the window if it is not maximized already + * Maximize the window if it is not maximized already. * * @param string $name window name (null for the main window) */ diff --git a/vendor/behat/mink/src/WebAssert.php b/vendor/behat/mink/src/WebAssert.php index 127c3c14b34..0f0e6fa71b9 100644 --- a/vendor/behat/mink/src/WebAssert.php +++ b/vendor/behat/mink/src/WebAssert.php @@ -49,7 +49,7 @@ class WebAssert public function addressEquals($page) { $expected = $this->cleanUrl($page); - $actual = $this->getCurrentUrlPath(); + $actual = $this->getCurrentUrlPath(); $this->assert($actual === $expected, sprintf('Current page is "%s", but "%s" expected.', $actual, $expected)); } @@ -64,7 +64,7 @@ class WebAssert public function addressNotEquals($page) { $expected = $this->cleanUrl($page); - $actual = $this->getCurrentUrlPath(); + $actual = $this->getCurrentUrlPath(); $this->assert($actual !== $expected, sprintf('Current page is "%s", but should not be.', $actual)); } @@ -85,7 +85,7 @@ class WebAssert } /** - * Checks that specified cookie exists and its value equals to a given one + * Checks that specified cookie exists and its value equals to a given one. * * @param string $name cookie name * @param string $value cookie value @@ -103,7 +103,7 @@ class WebAssert } /** - * Checks that specified cookie exists + * Checks that specified cookie exists. * * @param string $name cookie name * @@ -118,7 +118,7 @@ class WebAssert /** * Checks that current response code equals to provided one. * - * @param integer $code + * @param int $code * * @throws ExpectationException */ @@ -133,7 +133,7 @@ class WebAssert /** * Checks that current response code not equals to provided one. * - * @param integer $code + * @param int $code * * @throws ExpectationException */ @@ -145,6 +145,106 @@ class WebAssert $this->assert(intval($code) !== intval($actual), $message); } + /** + * Checks that current response header equals value. + * + * @param string $name + * @param string $value + * + * @throws ExpectationException + */ + public function responseHeaderEquals($name, $value) + { + $actual = $this->session->getResponseHeader($name); + $message = sprintf('Current response header "%s" is "%s", but "%s" expected.', $name, $actual, $value); + + $this->assert($value === $actual, $message); + } + + /** + * Checks that current response header does not equal value. + * + * @param string $name + * @param string $value + * + * @throws ExpectationException + */ + public function responseHeaderNotEquals($name, $value) + { + $actual = $this->session->getResponseHeader($name); + $message = sprintf('Current response header "%s" is "%s", but should not be.', $name, $actual, $value); + + $this->assert($value !== $actual, $message); + } + + /** + * Checks that current response header contains value. + * + * @param string $name + * @param string $value + * + * @throws ExpectationException + */ + public function responseHeaderContains($name, $value) + { + $actual = $this->session->getResponseHeader($name); + $message = sprintf('The text "%s" was not found anywhere in the "%s" response header.', $value, $name); + + $this->assert(false !== stripos($actual, $value), $message); + } + + /** + * Checks that current response header does not contain value. + * + * @param string $name + * @param string $value + * + * @throws ExpectationException + */ + public function responseHeaderNotContains($name, $value) + { + $actual = $this->session->getResponseHeader($name); + $message = sprintf('The text "%s" was found in the "%s" response header, but it should not.', $value, $name); + + $this->assert(false === stripos($actual, $value), $message); + } + + /** + * Checks that current response header matches regex. + * + * @param string $name + * @param string $regex + * + * @throws ExpectationException + */ + public function responseHeaderMatches($name, $regex) + { + $actual = $this->session->getResponseHeader($name); + $message = sprintf('The pattern "%s" was not found anywhere in the "%s" response header.', $regex, $name); + + $this->assert((bool) preg_match($regex, $actual), $message); + } + + /** + * Checks that current response header does not match regex. + * + * @param string $name + * @param string $regex + * + * @throws ExpectationException + */ + public function responseHeaderNotMatches($name, $regex) + { + $actual = $this->session->getResponseHeader($name); + $message = sprintf( + 'The pattern "%s" was found in the text of the "%s" response header, but it should not.', + $regex, + $name + ); + + $this->assert(!preg_match($regex, $actual), $message); + } + /** * Checks that current page contains text. * @@ -156,7 +256,7 @@ class WebAssert { $actual = $this->session->getPage()->getText(); $actual = preg_replace('/\s+/u', ' ', $actual); - $regex = '/'.preg_quote($text, '/').'/ui'; + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf('The text "%s" was not found anywhere in the text of the current page.', $text); $this->assertResponseText((bool) preg_match($regex, $actual), $message); @@ -173,7 +273,7 @@ class WebAssert { $actual = $this->session->getPage()->getText(); $actual = preg_replace('/\s+/u', ' ', $actual); - $regex = '/'.preg_quote($text, '/').'/ui'; + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf('The text "%s" appears in the text of this page, but it should not.', $text); $this->assertResponseText(!preg_match($regex, $actual), $message); @@ -219,7 +319,7 @@ class WebAssert public function responseContains($text) { $actual = $this->session->getPage()->getContent(); - $regex = '/'.preg_quote($text, '/').'/ui'; + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf('The string "%s" was not found anywhere in the HTML response of the current page.', $text); $this->assert((bool) preg_match($regex, $actual), $message); @@ -235,7 +335,7 @@ class WebAssert public function responseNotContains($text) { $actual = $this->session->getPage()->getContent(); - $regex = '/'.preg_quote($text, '/').'/ui'; + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf('The string "%s" appears in the HTML response of this page, but it should not.', $text); $this->assert(!preg_match($regex, $actual), $message); @@ -276,7 +376,7 @@ class WebAssert * * @param string $selectorType element selector type (css, xpath) * @param string|array $selector element selector - * @param integer $count expected count + * @param int $count expected count * @param ElementInterface $container document to check against * * @throws ExpectationException @@ -317,7 +417,7 @@ class WebAssert $selector = implode(' ', $selector); } - throw new ElementNotFoundException($this->session, 'element', $selectorType, $selector); + throw new ElementNotFoundException($this->session->getDriver(), 'element', $selectorType, $selector); } return $node; @@ -357,8 +457,8 @@ class WebAssert public function elementTextContains($selectorType, $selector, $text) { $element = $this->elementExists($selectorType, $selector); - $actual = $element->getText(); - $regex = '/'.preg_quote($text, '/').'/ui'; + $actual = $element->getText(); + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf( 'The text "%s" was not found in the text of the %s.', @@ -381,8 +481,8 @@ class WebAssert public function elementTextNotContains($selectorType, $selector, $text) { $element = $this->elementExists($selectorType, $selector); - $actual = $element->getText(); - $regex = '/'.preg_quote($text, '/').'/ui'; + $actual = $element->getText(); + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf( 'The text "%s" appears in the text of the %s, but it should not.', @@ -405,8 +505,8 @@ class WebAssert public function elementContains($selectorType, $selector, $html) { $element = $this->elementExists($selectorType, $selector); - $actual = $element->getHtml(); - $regex = '/'.preg_quote($html, '/').'/ui'; + $actual = $element->getHtml(); + $regex = '/'.preg_quote($html, '/').'/ui'; $message = sprintf( 'The string "%s" was not found in the HTML of the %s.', @@ -429,8 +529,8 @@ class WebAssert public function elementNotContains($selectorType, $selector, $html) { $element = $this->elementExists($selectorType, $selector); - $actual = $element->getHtml(); - $regex = '/'.preg_quote($html, '/').'/ui'; + $actual = $element->getHtml(); + $regex = '/'.preg_quote($html, '/').'/ui'; $message = sprintf( 'The string "%s" appears in the HTML of the %s, but it should not.', @@ -480,8 +580,8 @@ class WebAssert public function elementAttributeContains($selectorType, $selector, $attribute, $text) { $element = $this->elementAttributeExists($selectorType, $selector, $attribute); - $actual = $element->getAttribute($attribute); - $regex = '/'.preg_quote($text, '/').'/ui'; + $actual = $element->getAttribute($attribute); + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf( 'The text "%s" was not found in the attribute "%s" of the %s.', @@ -506,8 +606,8 @@ class WebAssert public function elementAttributeNotContains($selectorType, $selector, $attribute, $text) { $element = $this->elementAttributeExists($selectorType, $selector, $attribute); - $actual = $element->getAttribute($attribute); - $regex = '/'.preg_quote($text, '/').'/ui'; + $actual = $element->getAttribute($attribute); + $regex = '/'.preg_quote($text, '/').'/ui'; $message = sprintf( 'The text "%s" was found in the attribute "%s" of the %s.', @@ -535,7 +635,7 @@ class WebAssert $node = $container->findField($field); if (null === $node) { - throw new ElementNotFoundException($this->session, 'form field', 'id|name|label|value', $field); + throw new ElementNotFoundException($this->session->getDriver(), 'form field', 'id|name|label|value', $field); } return $node; @@ -568,9 +668,9 @@ class WebAssert */ public function fieldValueEquals($field, $value, TraversableElement $container = null) { - $node = $this->fieldExists($field, $container); + $node = $this->fieldExists($field, $container); $actual = $node->getValue(); - $regex = '/^'.preg_quote($value, '/').'$/ui'; + $regex = '/^'.preg_quote($value, '/').'$/ui'; $message = sprintf('The field "%s" value is "%s", but "%s" expected.', $field, $actual, $value); @@ -588,9 +688,9 @@ class WebAssert */ public function fieldValueNotEquals($field, $value, TraversableElement $container = null) { - $node = $this->fieldExists($field, $container); + $node = $this->fieldExists($field, $container); $actual = $node->getValue(); - $regex = '/^'.preg_quote($value, '/').'$/ui'; + $regex = '/^'.preg_quote($value, '/').'$/ui'; $message = sprintf('The field "%s" value is "%s", but it should not be.', $field, $actual); @@ -650,7 +750,7 @@ class WebAssert $fragment = empty($parts['fragment']) ? '' : '#'.$parts['fragment']; $path = empty($parts['path']) ? '/' : $parts['path']; - return preg_replace('/^\/[^\.\/]+\.php/', '', $path).$fragment; + return preg_replace('/^\/[^\.\/]+\.php\//', '/', $path).$fragment; } /** @@ -667,7 +767,7 @@ class WebAssert return; } - throw new ExpectationException($message, $this->session); + throw new ExpectationException($message, $this->session->getDriver()); } /** @@ -684,7 +784,7 @@ class WebAssert return; } - throw new ResponseTextException($message, $this->session); + throw new ResponseTextException($message, $this->session->getDriver()); } /** @@ -702,7 +802,7 @@ class WebAssert return; } - throw new ElementHtmlException($message, $this->session, $element); + throw new ElementHtmlException($message, $this->session->getDriver(), $element); } /** @@ -720,13 +820,13 @@ class WebAssert return; } - throw new ElementTextException($message, $this->session, $element); + throw new ElementTextException($message, $this->session->getDriver(), $element); } /** * @param string $selectorType * @param string|array $selector - * @param boolean $plural + * @param bool $plural * * @return string */ diff --git a/vendor/behat/mink/tests/Driver/CoreDriverTest.php b/vendor/behat/mink/tests/Driver/CoreDriverTest.php index d99b17f6e9a..cd1fe6436ba 100644 --- a/vendor/behat/mink/tests/Driver/CoreDriverTest.php +++ b/vendor/behat/mink/tests/Driver/CoreDriverTest.php @@ -2,6 +2,8 @@ namespace Behat\Mink\Tests\Driver; +use Behat\Mink\Element\NodeElement; + class CoreDriverTest extends \PHPUnit_Framework_TestCase { public function testNoExtraMethods() @@ -17,6 +19,34 @@ class CoreDriverTest extends \PHPUnit_Framework_TestCase } } + public function testCreateNodeElements() + { + $driver = $this->getMockBuilder('Behat\Mink\Driver\CoreDriver') + ->setMethods(array('findElementXpaths')) + ->getMockForAbstractClass(); + + $session = $this->getMockBuilder('Behat\Mink\Session') + ->disableOriginalConstructor() + ->getMock(); + + $driver->setSession($session); + + $driver->expects($this->once()) + ->method('findElementXpaths') + ->with('xpath') + ->willReturn(array('xpath1', 'xpath2')); + + /** @var NodeElement[] $elements */ + $elements = $driver->find('xpath'); + + $this->assertInternalType('array', $elements); + $this->assertCount(2, $elements); + $this->assertContainsOnlyInstancesOf('Behat\Mink\Element\NodeElement', $elements); + + $this->assertSame('xpath1', $elements[0]->getXpath()); + $this->assertSame('xpath2', $elements[1]->getXpath()); + } + /** * @dataProvider getDriverInterfaceMethods */ @@ -29,6 +59,10 @@ class CoreDriverTest extends \PHPUnit_Framework_TestCase sprintf('CoreDriver should implement a dummy %s method', $method->getName()) ); + if ('setSession' === $method->getName()) { + return; // setSession is actually implemented, so we don't expect an exception here. + } + $driver = $this->getMockForAbstractClass('Behat\Mink\Driver\CoreDriver'); $this->setExpectedException('Behat\Mink\Exception\UnsupportedDriverActionException'); diff --git a/vendor/behat/mink/tests/Element/DocumentElementTest.php b/vendor/behat/mink/tests/Element/DocumentElementTest.php index bacd06d8d60..2105ab785e8 100644 --- a/vendor/behat/mink/tests/Element/DocumentElementTest.php +++ b/vendor/behat/mink/tests/Element/DocumentElementTest.php @@ -19,6 +19,9 @@ class DocumentElementTest extends ElementTest $this->document = new DocumentElement($this->session); } + /** + * @group legacy + */ public function testGetSession() { $this->assertEquals($this->session, $this->document->getSession()); diff --git a/vendor/behat/mink/tests/Element/ElementTest.php b/vendor/behat/mink/tests/Element/ElementTest.php index a8c8a8ca90d..650284c870c 100644 --- a/vendor/behat/mink/tests/Element/ElementTest.php +++ b/vendor/behat/mink/tests/Element/ElementTest.php @@ -36,11 +36,6 @@ abstract class ElementTest extends \PHPUnit_Framework_TestCase $this->selectors = $this->getMockBuilder('Behat\Mink\Selector\SelectorsHandler')->getMock(); $this->session = new Session($this->driver, $this->selectors); - - $this->selectors - ->expects($this->any()) - ->method('xpathLiteral') - ->will($this->returnArgument(0)); } protected function mockNamedFinder($xpath, array $results, $locator, $times = 2) @@ -55,7 +50,7 @@ abstract class ElementTest extends \PHPUnit_Framework_TestCase $processedResults[] = $result; if (empty($result)) { $processedResults[] = $result; - $times++; + ++$times; } } diff --git a/vendor/behat/mink/tests/Element/NodeElementTest.php b/vendor/behat/mink/tests/Element/NodeElementTest.php index b6a8bdeb0c9..f769dddb939 100644 --- a/vendor/behat/mink/tests/Element/NodeElementTest.php +++ b/vendor/behat/mink/tests/Element/NodeElementTest.php @@ -76,7 +76,7 @@ class NodeElementTest extends ElementTest $node = new NodeElement('some xpath', $this->session); $result = $node->waitFor(5, function ($givenNode) use (&$callCounter) { - $callCounter++; + ++$callCounter; if (1 === $callCounter) { return null; @@ -93,6 +93,9 @@ class NodeElementTest extends ElementTest $this->assertSame($node, $result, '->waitFor() returns node found in callback'); } + /** + * @medium + */ public function testWaitForTimeout() { $node = new NodeElement('some xpath', $this->session); @@ -153,11 +156,13 @@ class NodeElementTest extends ElementTest ->expects($this->exactly(6)) ->method('getAttribute') ->with('input_tag', 'class') - ->will($this->returnValue('class1 class2')); + ->will($this->returnValue(' + class1 class2 + ')); - $this->assertTrue($node->hasClass('class1')); - $this->assertTrue($node->hasClass('class2')); - $this->assertFalse($node->hasClass('class3')); + $this->assertTrue($node->hasClass('class1'), 'The "class1" was found'); + $this->assertTrue($node->hasClass('class2'), 'The "class2" was found'); + $this->assertFalse($node->hasClass('class3'), 'The "class3" was not found'); } public function testHasClassWithoutArgument() @@ -571,8 +576,8 @@ class NodeElementTest extends ElementTest public function testFindAllParentUnion() { $node = new NodeElement('some_xpath | another_xpath', $this->session); - $xpath = "some_tag1 | some_tag2"; - $expectedPrefixed = "(some_xpath | another_xpath)/some_tag1 | (some_xpath | another_xpath)/some_tag2"; + $xpath = 'some_tag1 | some_tag2'; + $expectedPrefixed = '(some_xpath | another_xpath)/some_tag1 | (some_xpath | another_xpath)/some_tag2'; $this->driver ->expects($this->exactly(1)) diff --git a/vendor/behat/mink/tests/Exception/ElementExceptionTest.php b/vendor/behat/mink/tests/Exception/ElementExceptionTest.php index 021e8d58782..87bf2ca46cc 100644 --- a/vendor/behat/mink/tests/Exception/ElementExceptionTest.php +++ b/vendor/behat/mink/tests/Exception/ElementExceptionTest.php @@ -4,6 +4,9 @@ namespace Behat\Mink\Tests\Exception; use Behat\Mink\Exception\ElementException; +/** + * @group legacy + */ class ElementExceptionTest extends \PHPUnit_Framework_TestCase { public function testMessage() diff --git a/vendor/behat/mink/tests/Exception/ElementHtmlExceptionTest.php b/vendor/behat/mink/tests/Exception/ElementHtmlExceptionTest.php index 63d39dd0c4c..7d6ea8252e3 100644 --- a/vendor/behat/mink/tests/Exception/ElementHtmlExceptionTest.php +++ b/vendor/behat/mink/tests/Exception/ElementHtmlExceptionTest.php @@ -11,14 +11,10 @@ class ElementHtmlExceptionTest extends \PHPUnit_Framework_TestCase $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); $element = $this->getElementMock(); - $session = $this->getSessionMock(); - $session->expects($this->any()) - ->method('getDriver') - ->will($this->returnValue($driver)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getStatusCode') ->will($this->returnValue(200)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getCurrentUrl') ->will($this->returnValue('http://localhost/test')); @@ -40,18 +36,11 @@ TXT; $expected = sprintf($expected.' ', get_class($driver)); - $exception = new ElementHtmlException('Html error', $session, $element); + $exception = new ElementHtmlException('Html error', $driver, $element); $this->assertEquals($expected, $exception->__toString()); } - private function getSessionMock() - { - return $this->getMockBuilder('Behat\Mink\Session') - ->disableOriginalConstructor() - ->getMock(); - } - private function getElementMock() { return $this->getMockBuilder('Behat\Mink\Element\NodeElement') diff --git a/vendor/behat/mink/tests/Exception/ElementNotFoundExceptionTest.php b/vendor/behat/mink/tests/Exception/ElementNotFoundExceptionTest.php index 8cb4e5d8922..6faa55c5320 100644 --- a/vendor/behat/mink/tests/Exception/ElementNotFoundExceptionTest.php +++ b/vendor/behat/mink/tests/Exception/ElementNotFoundExceptionTest.php @@ -11,11 +11,9 @@ class ElementNotFoundExceptionTest extends \PHPUnit_Framework_TestCase */ public function testBuildMessage($message, $type, $selector = null, $locator = null) { - $session = $this->getMockBuilder('Behat\Mink\Session') - ->disableOriginalConstructor() - ->getMock(); + $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); - $exception = new ElementNotFoundException($session, $type, $selector, $locator); + $exception = new ElementNotFoundException($driver, $type, $selector, $locator); $this->assertEquals($message, $exception->getMessage()); } @@ -31,4 +29,22 @@ class ElementNotFoundExceptionTest extends \PHPUnit_Framework_TestCase array('Tag with name "foobar" not found.', null, 'name', 'foobar'), ); } + + /** + * @group legacy + */ + public function testConstructWithSession() + { + $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); + $session = $this->getMockBuilder('Behat\Mink\Session') + ->disableOriginalConstructor() + ->getMock(); + $session->expects($this->any()) + ->method('getDriver') + ->will($this->returnValue($driver)); + + $exception = new ElementNotFoundException($session); + + $this->assertEquals('Tag not found.', $exception->getMessage()); + } } diff --git a/vendor/behat/mink/tests/Exception/ElementTextExceptionTest.php b/vendor/behat/mink/tests/Exception/ElementTextExceptionTest.php index 73cef5bc346..f8d5e4c8e49 100644 --- a/vendor/behat/mink/tests/Exception/ElementTextExceptionTest.php +++ b/vendor/behat/mink/tests/Exception/ElementTextExceptionTest.php @@ -11,14 +11,10 @@ class ElementTextExceptionTest extends \PHPUnit_Framework_TestCase $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); $element = $this->getElementMock(); - $session = $this->getSessionMock(); - $session->expects($this->any()) - ->method('getDriver') - ->will($this->returnValue($driver)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getStatusCode') ->will($this->returnValue(200)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getCurrentUrl') ->will($this->returnValue('http://localhost/test')); @@ -38,18 +34,11 @@ TXT; $expected = sprintf($expected.' ', get_class($driver)); - $exception = new ElementTextException('Text error', $session, $element); + $exception = new ElementTextException('Text error', $driver, $element); $this->assertEquals($expected, $exception->__toString()); } - private function getSessionMock() - { - return $this->getMockBuilder('Behat\Mink\Session') - ->disableOriginalConstructor() - ->getMock(); - } - private function getElementMock() { return $this->getMockBuilder('Behat\Mink\Element\NodeElement') diff --git a/vendor/behat/mink/tests/Exception/ExpectationExceptionTest.php b/vendor/behat/mink/tests/Exception/ExpectationExceptionTest.php index 466bcca63ec..a327fcbd670 100644 --- a/vendor/behat/mink/tests/Exception/ExpectationExceptionTest.php +++ b/vendor/behat/mink/tests/Exception/ExpectationExceptionTest.php @@ -8,7 +8,7 @@ class ExpectationExceptionTest extends \PHPUnit_Framework_TestCase { public function testEmptyMessageAndPreviousException() { - $exception = new ExpectationException('', $this->getSessionMock(), new \Exception('Something failed')); + $exception = new ExpectationException('', $this->getMock('Behat\Mink\Driver\DriverInterface'), new \Exception('Something failed')); $this->assertEquals('Something failed', $exception->getMessage()); } @@ -16,24 +16,16 @@ class ExpectationExceptionTest extends \PHPUnit_Framework_TestCase public function testExceptionToString() { $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); - $page = $this->getPageMock(); - $session = $this->getSessionMock(); - $session->expects($this->any()) - ->method('getDriver') - ->will($this->returnValue($driver)); - $session->expects($this->any()) - ->method('getPage') - ->will($this->returnValue($page)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getStatusCode') ->will($this->returnValue(200)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getCurrentUrl') ->will($this->returnValue('http://localhost/test')); $html = "<html><head><title>Hello</title></head>\n<body>\n<h1>Hello world</h1>\n<p>Test</p>\n</body></html>"; - $page->expects($this->any()) + $driver->expects($this->any()) ->method('getContent') ->will($this->returnValue($html)); @@ -51,7 +43,7 @@ TXT; $expected = sprintf($expected.' ', get_class($driver)); - $exception = new ExpectationException('Expectation failure', $session); + $exception = new ExpectationException('Expectation failure', $driver); $this->assertEquals($expected, $exception->__toString()); } @@ -59,26 +51,18 @@ TXT; public function testBigContent() { $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); - $page = $this->getPageMock(); - $session = $this->getSessionMock(); - $session->expects($this->any()) - ->method('getDriver') - ->will($this->returnValue($driver)); - $session->expects($this->any()) - ->method('getPage') - ->will($this->returnValue($page)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getStatusCode') ->will($this->returnValue(200)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getCurrentUrl') ->will($this->returnValue('http://localhost/test')); $body = str_repeat('a', 1001 - strlen('<body></body>')); $html = sprintf("<html><head><title>Hello</title></head>\n<body>%s</body></html>", $body); - $page->expects($this->any()) + $driver->expects($this->any()) ->method('getContent') ->will($this->returnValue($html)); @@ -93,34 +77,38 @@ TXT; $expected = sprintf($expected.' ', get_class($driver), $body); - $exception = new ExpectationException('Expectation failure', $session); + $exception = new ExpectationException('Expectation failure', $driver); $this->assertEquals($expected, $exception->__toString()); } public function testExceptionWhileRenderingString() { - $session = $this->getSessionMock(); - $session->expects($this->any()) - ->method('getPage') + $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); + $driver->expects($this->any()) + ->method('getContent') ->will($this->throwException(new \Exception('Broken page'))); - $exception = new ExpectationException('Expectation failure', $session); + $exception = new ExpectationException('Expectation failure', $driver); $this->assertEquals('Expectation failure', $exception->__toString()); } - private function getSessionMock() + /** + * @group legacy + */ + public function testConstructWithSession() { - return $this->getMockBuilder('Behat\Mink\Session') + $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); + $session = $this->getMockBuilder('Behat\Mink\Session') ->disableOriginalConstructor() ->getMock(); - } + $session->expects($this->any()) + ->method('getDriver') + ->will($this->returnValue($driver)); - private function getPageMock() - { - return $this->getMockBuilder('Behat\Mink\Element\DocumentElement') - ->disableOriginalConstructor() - ->getMock(); + $exception = new ExpectationException('', $session, new \Exception('Something failed')); + + $this->assertEquals('Something failed', $exception->getMessage()); } } diff --git a/vendor/behat/mink/tests/Exception/ResponseTextExceptionTest.php b/vendor/behat/mink/tests/Exception/ResponseTextExceptionTest.php index 4651b7cd5aa..429721dd9df 100644 --- a/vendor/behat/mink/tests/Exception/ResponseTextExceptionTest.php +++ b/vendor/behat/mink/tests/Exception/ResponseTextExceptionTest.php @@ -9,24 +9,16 @@ class ResponseTextExceptionTest extends \PHPUnit_Framework_TestCase public function testExceptionToString() { $driver = $this->getMock('Behat\Mink\Driver\DriverInterface'); - $page = $this->getPageMock(); - - $session = $this->getSessionMock(); - $session->expects($this->any()) - ->method('getDriver') - ->will($this->returnValue($driver)); - $session->expects($this->any()) - ->method('getPage') - ->will($this->returnValue($page)); - $session->expects($this->any()) + + $driver->expects($this->any()) ->method('getStatusCode') ->will($this->returnValue(200)); - $session->expects($this->any()) + $driver->expects($this->any()) ->method('getCurrentUrl') ->will($this->returnValue('http://localhost/test')); - - $page->expects($this->any()) + $driver->expects($this->any()) ->method('getText') + ->with('//html') ->will($this->returnValue("Hello world\nTest\n")); $expected = <<<'TXT' @@ -41,22 +33,8 @@ TXT; $expected = sprintf($expected.' ', get_class($driver)); - $exception = new ResponseTextException('Text error', $session); + $exception = new ResponseTextException('Text error', $driver); $this->assertEquals($expected, $exception->__toString()); } - - private function getSessionMock() - { - return $this->getMockBuilder('Behat\Mink\Session') - ->disableOriginalConstructor() - ->getMock(); - } - - private function getPageMock() - { - return $this->getMockBuilder('Behat\Mink\Element\DocumentElement') - ->disableOriginalConstructor() - ->getMock(); - } } diff --git a/vendor/behat/mink/tests/Selector/NamedSelectorTest.php b/vendor/behat/mink/tests/Selector/NamedSelectorTest.php index e0de1bc226d..5124a4628cb 100644 --- a/vendor/behat/mink/tests/Selector/NamedSelectorTest.php +++ b/vendor/behat/mink/tests/Selector/NamedSelectorTest.php @@ -3,7 +3,7 @@ namespace Behat\Mink\Tests\Selector; use Behat\Mink\Selector\NamedSelector; -use Behat\Mink\Selector\SelectorsHandler; +use Behat\Mink\Selector\Xpath\Escaper; abstract class NamedSelectorTest extends \PHPUnit_Framework_TestCase { @@ -42,10 +42,6 @@ abstract class NamedSelectorTest extends \PHPUnit_Framework_TestCase $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->loadHTML(file_get_contents(__DIR__.'/fixtures/'.$fixtureFile)); - // Escape the locator as Mink 1.x expects the caller of the NamedSelector to handle it - $selectorsHandler = new SelectorsHandler(); - $locator = $selectorsHandler->xpathLiteral($locator); - $namedSelector = $this->getSelector(); $xpath = $namedSelector->translateToXPath(array($selector, $locator)); @@ -56,6 +52,19 @@ abstract class NamedSelectorTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedCount, $nodeList->length); } + /** + * @dataProvider getSelectorTests + * @group legacy + */ + public function testEscapedSelectors($fixtureFile, $selector, $locator, $expectedExactCount, $expectedPartialCount = null) + { + // Escape the locator as Mink 1.x expects the caller of the NamedSelector to handle it + $escaper = new Escaper(); + $locator = $escaper->escapeLiteral($locator); + + $this->testSelectors($fixtureFile, $selector, $locator, $expectedExactCount, $expectedPartialCount); + } + public function getSelectorTests() { $fieldCount = 8; // fields without `type` attribute @@ -122,6 +131,7 @@ abstract class NamedSelectorTest extends \PHPUnit_Framework_TestCase // 3 matches, because matches every HTML node in path: html > body > div 'content' => array('test.html', 'content', 'content-text', 1, 4), + 'content with quotes' => array('test.html', 'content', 'some "quoted" content', 1, 3), 'select (name/label)' => array('test.html', 'select', 'the-field', 3), 'select (with-id)' => array('test.html', 'select', 'the-field-select', 1), @@ -152,7 +162,7 @@ abstract class NamedSelectorTest extends \PHPUnit_Framework_TestCase abstract protected function getSelector(); /** - * @return boolean + * @return bool */ abstract protected function allowPartialMatch(); } diff --git a/vendor/behat/mink/tests/Selector/SelectorsHandlerTest.php b/vendor/behat/mink/tests/Selector/SelectorsHandlerTest.php index a20d3d9db7f..fb63b329dcd 100644 --- a/vendor/behat/mink/tests/Selector/SelectorsHandlerTest.php +++ b/vendor/behat/mink/tests/Selector/SelectorsHandlerTest.php @@ -71,6 +71,9 @@ class SelectorsHandlerTest extends \PHPUnit_Framework_TestCase $handler->selectorToXpath('undefined', 'asd'); } + /** + * @group legacy + */ public function testXpathLiteral() { $handler = new SelectorsHandler(); @@ -78,6 +81,9 @@ class SelectorsHandlerTest extends \PHPUnit_Framework_TestCase $this->assertEquals("'some simple string'", $handler->xpathLiteral('some simple string')); } + /** + * @group legacy + */ public function testBcLayer() { $selector = $this->getMockBuilder('Behat\Mink\Selector\SelectorInterface')->getMock(); @@ -85,8 +91,6 @@ class SelectorsHandlerTest extends \PHPUnit_Framework_TestCase $handler->registerSelector('named_partial', $selector); - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->assertSame($selector, $handler->getSelector('named')); } } diff --git a/vendor/behat/mink/tests/Selector/fixtures/test.html b/vendor/behat/mink/tests/Selector/fixtures/test.html index c64ae103292..1190e9ea600 100644 --- a/vendor/behat/mink/tests/Selector/fixtures/test.html +++ b/vendor/behat/mink/tests/Selector/fixtures/test.html @@ -66,6 +66,8 @@ some content-text </div> + <div>some "quoted" content</div> + <form> <div id="test-for-field-selector"> <!-- match fields by `id` attribute --> diff --git a/vendor/behat/mink/tests/SessionTest.php b/vendor/behat/mink/tests/SessionTest.php index 9e6796db993..3e0104a71c5 100644 --- a/vendor/behat/mink/tests/SessionTest.php +++ b/vendor/behat/mink/tests/SessionTest.php @@ -130,6 +130,29 @@ class SessionTest extends \PHPUnit_Framework_TestCase $this->assertEquals($ret, $this->session->getResponseHeaders()); } + /** + * @dataProvider provideResponseHeader + */ + public function testGetResponseHeader($expected, $name, array $headers) + { + $this->driver->expects($this->once()) + ->method('getResponseHeaders') + ->willReturn($headers); + + $this->assertSame($expected, $this->session->getResponseHeader($name)); + } + + public function provideResponseHeader() + { + return array( + array('test', 'Mink', array('Mink' => 'test')), + array('test', 'mink', array('Mink' => 'test')), + array('test', 'Mink', array('mink' => 'test')), + array('test', 'Mink', array('Mink' => array('test', 'test2'))), + array(null, 'other', array('Mink' => 'test')), + ); + } + public function testSetCookie() { $this->driver->expects($this->once()) diff --git a/vendor/behat/mink/tests/WebAssertTest.php b/vendor/behat/mink/tests/WebAssertTest.php index c3bd3cf11c1..ef55d2d2ee2 100644 --- a/vendor/behat/mink/tests/WebAssertTest.php +++ b/vendor/behat/mink/tests/WebAssertTest.php @@ -21,6 +21,10 @@ class WebAssertTest extends \PHPUnit_Framework_TestCase $this->session = $this->getMockBuilder('Behat\\Mink\\Session') ->disableOriginalConstructor() ->getMock(); + $this->session->expects($this->any()) + ->method('getDriver') + ->will($this->returnValue($this->getMock('Behat\Mink\Driver\DriverInterface'))); + $this->assert = new WebAssert($this->session); } @@ -52,6 +56,23 @@ class WebAssertTest extends \PHPUnit_Framework_TestCase $this->assertCorrectAssertion('addressEquals', array('/')); } + public function testAddressEqualsEndingInScript() + { + $this->session + ->expects($this->exactly(2)) + ->method('getCurrentUrl') + ->will($this->returnValue('http://example.com/script.php')) + ; + + $this->assertCorrectAssertion('addressEquals', array('/script.php')); + $this->assertWrongAssertion( + 'addressEquals', + array('/'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'Current page is "/script.php", but "/" expected.' + ); + } + public function testAddressNotEquals() { $this->session @@ -69,6 +90,23 @@ class WebAssertTest extends \PHPUnit_Framework_TestCase ); } + public function testAddressNotEqualsEndingInScript() + { + $this->session + ->expects($this->exactly(2)) + ->method('getCurrentUrl') + ->will($this->returnValue('http://example.com/script.php')) + ; + + $this->assertCorrectAssertion('addressNotEquals', array('/')); + $this->assertWrongAssertion( + 'addressNotEquals', + array('/script.php'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'Current page is "/script.php", but should not be.' + ); + } + public function testAddressMatches() { $this->session @@ -162,6 +200,132 @@ class WebAssertTest extends \PHPUnit_Framework_TestCase ); } + public function testResponseHeaderEquals() + { + $this->session + ->expects($this->any()) + ->method('getResponseHeader') + ->will($this->returnValueMap( + array( + array('foo', 'bar'), + array('bar', 'baz'), + ) + )); + + $this->assertCorrectAssertion('responseHeaderEquals', array('foo', 'bar')); + $this->assertWrongAssertion( + 'responseHeaderEquals', + array('bar', 'foo'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'Current response header "bar" is "baz", but "foo" expected.' + ); + } + + public function testResponseHeaderNotEquals() + { + $this->session + ->expects($this->any()) + ->method('getResponseHeader') + ->will($this->returnValueMap( + array( + array('foo', 'bar'), + array('bar', 'baz'), + ) + )); + + $this->assertCorrectAssertion('responseHeaderNotEquals', array('foo', 'baz')); + $this->assertWrongAssertion( + 'responseHeaderNotEquals', + array('bar', 'baz'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'Current response header "bar" is "baz", but should not be.' + ); + } + + public function testResponseHeaderContains() + { + $this->session + ->expects($this->any()) + ->method('getResponseHeader') + ->will($this->returnValueMap( + array( + array('foo', 'bar'), + array('bar', 'baz'), + ) + )); + + $this->assertCorrectAssertion('responseHeaderContains', array('foo', 'ba')); + $this->assertWrongAssertion( + 'responseHeaderContains', + array('bar', 'bz'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'The text "bz" was not found anywhere in the "bar" response header.' + ); + } + + public function testResponseHeaderNotContains() + { + $this->session + ->expects($this->any()) + ->method('getResponseHeader') + ->will($this->returnValueMap( + array( + array('foo', 'bar'), + array('bar', 'baz'), + ) + )); + + $this->assertCorrectAssertion('responseHeaderNotContains', array('foo', 'bz')); + $this->assertWrongAssertion( + 'responseHeaderNotContains', + array('bar', 'ba'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'The text "ba" was found in the "bar" response header, but it should not.' + ); + } + + public function testResponseHeaderMatches() + { + $this->session + ->expects($this->any()) + ->method('getResponseHeader') + ->will($this->returnValueMap( + array( + array('foo', 'bar'), + array('bar', 'baz'), + ) + )); + + $this->assertCorrectAssertion('responseHeaderMatches', array('foo', '/ba(.*)/')); + $this->assertWrongAssertion( + 'responseHeaderMatches', + array('bar', '/b[^a]/'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'The pattern "/b[^a]/" was not found anywhere in the "bar" response header.' + ); + } + + public function testResponseHeaderNotMatches() + { + $this->session + ->expects($this->any()) + ->method('getResponseHeader') + ->will($this->returnValueMap( + array( + array('foo', 'bar'), + array('bar', 'baz'), + ) + )); + + $this->assertCorrectAssertion('responseHeaderNotMatches', array('foo', '/bz/')); + $this->assertWrongAssertion( + 'responseHeaderNotMatches', + array('bar', '/b[ab]z/'), + 'Behat\\Mink\\Exception\\ExpectationException', + 'The pattern "/b[ab]z/" was found in the text of the "bar" response header, but it should not.' + ); + } + public function testPageTextContains() { $page = $this->getMockBuilder('Behat\\Mink\\Element\\DocumentElement') diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 4d9994fd2a2..9b86e3b1f3f 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -18,5 +18,4 @@ return array( 'PHPQRCode' => array($vendorDir . '/aferrandini/phpqrcode/lib'), 'LosReCaptcha\\' => array($vendorDir . '/los/losrecaptcha/src'), 'Less' => array($vendorDir . '/oyejorge/less.php/lib'), - 'Behat\\Mink\\Driver' => array($vendorDir . '/behat/mink-zombie-driver/src'), ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index d62617bbcfe..698b2095755 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -11,5 +11,6 @@ return array( 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), 'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'), 'LosReCaptcha\\' => array($vendorDir . '/los/losrecaptcha/src'), + 'Behat\\Mink\\Driver\\' => array($vendorDir . '/behat/mink-zombie-driver/src'), 'Behat\\Mink\\' => array($vendorDir . '/behat/mink/src'), ); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 6ec4600b736..31118853a26 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -171,123 +171,6 @@ ], "description": "Library for interacting with Serials Solutions' Summon API." }, - { - "name": "behat/mink", - "version": "v1.6.1", - "version_normalized": "1.6.1.0", - "source": { - "type": "git", - "url": "https://github.com/minkphp/Mink.git", - "reference": "8b68523a339ec991bcd638b39dc8f04f808da88a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/minkphp/Mink/zipball/8b68523a339ec991bcd638b39dc8f04f808da88a", - "reference": "8b68523a339ec991bcd638b39dc8f04f808da88a", - "shasum": "" - }, - "require": { - "php": ">=5.3.1", - "symfony/css-selector": "~2.0" - }, - "suggest": { - "behat/mink-browserkit-driver": "extremely fast headless driver for Symfony\\Kernel-based apps (Sf2, Silex)", - "behat/mink-goutte-driver": "fast headless driver for any app without JS emulation", - "behat/mink-selenium2-driver": "slow, but JS-enabled driver for any app (requires Selenium2)", - "behat/mink-zombie-driver": "fast and JS-enabled headless driver for any app (requires node.js)" - }, - "time": "2015-02-04 17:02:06", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Behat\\Mink\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - } - ], - "description": "Browser controller/emulator abstraction for PHP", - "homepage": "http://mink.behat.org/", - "keywords": [ - "browser", - "testing", - "web" - ] - }, - { - "name": "behat/mink-zombie-driver", - "version": "v1.2.0", - "version_normalized": "1.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/minkphp/MinkZombieDriver.git", - "reference": "cf15a3a0cc4865bb55253cd033a03a20cee6d2d1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/minkphp/MinkZombieDriver/zipball/cf15a3a0cc4865bb55253cd033a03a20cee6d2d1", - "reference": "cf15a3a0cc4865bb55253cd033a03a20cee6d2d1", - "shasum": "" - }, - "require": { - "behat/mink": "~1.6@dev", - "php": ">=5.3.1", - "symfony/process": "~2.1" - }, - "time": "2014-09-26 12:26:25", - "type": "mink-driver", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Behat\\Mink\\Driver": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Pascal Cremer", - "email": "b00gizm@gmail.com", - "homepage": "http://github.com/b00gizm" - } - ], - "description": "Zombie.js driver for Mink framework", - "homepage": "http://mink.behat.org/", - "keywords": [ - "ajax", - "browser", - "headless", - "javascript", - "testing", - "zombie" - ] - }, { "name": "los/losrecaptcha", "version": "1.0.0", @@ -1388,5 +1271,129 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com" + }, + { + "name": "behat/mink", + "version": "v1.7.0", + "version_normalized": "1.7.0.0", + "source": { + "type": "git", + "url": "https://github.com/minkphp/Mink.git", + "reference": "6c129030ec2cc029905cf969a56ca8f087b2dfdf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/minkphp/Mink/zipball/6c129030ec2cc029905cf969a56ca8f087b2dfdf", + "reference": "6c129030ec2cc029905cf969a56ca8f087b2dfdf", + "shasum": "" + }, + "require": { + "php": ">=5.3.1", + "symfony/css-selector": "~2.1" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "suggest": { + "behat/mink-browserkit-driver": "extremely fast headless driver for Symfony\\Kernel-based apps (Sf2, Silex)", + "behat/mink-goutte-driver": "fast headless driver for any app without JS emulation", + "behat/mink-selenium2-driver": "slow, but JS-enabled driver for any app (requires Selenium2)", + "behat/mink-zombie-driver": "fast and JS-enabled headless driver for any app (requires node.js)" + }, + "time": "2015-09-20 20:24:03", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Behat\\Mink\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + } + ], + "description": "Browser controller/emulator abstraction for PHP", + "homepage": "http://mink.behat.org/", + "keywords": [ + "browser", + "testing", + "web" + ] + }, + { + "name": "behat/mink-zombie-driver", + "version": "v1.3.0", + "version_normalized": "1.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/minkphp/MinkZombieDriver.git", + "reference": "257a2d46ffdc8cba28d107c2f1368fc1e5637d1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/minkphp/MinkZombieDriver/zipball/257a2d46ffdc8cba28d107c2f1368fc1e5637d1b", + "reference": "257a2d46ffdc8cba28d107c2f1368fc1e5637d1b", + "shasum": "" + }, + "require": { + "behat/mink": "~1.7@dev", + "ext-sockets": "*", + "php": ">=5.3.1", + "symfony/process": "~2.1" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "time": "2015-09-21 21:07:53", + "type": "mink-driver", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Behat\\Mink\\Driver\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Pascal Cremer", + "email": "b00gizm@gmail.com", + "homepage": "http://github.com/b00gizm" + } + ], + "description": "Zombie.js driver for Mink framework", + "homepage": "http://mink.behat.org/", + "keywords": [ + "ajax", + "browser", + "headless", + "javascript", + "testing", + "zombie" + ] } ] -- GitLab