diff --git a/.travis.yml b/.travis.yml index 497273f7..ff153ad6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,7 @@ matrix: allow_failures: - php: hhvm -before_script: ./.ci/before_script.sh +before_script: + - ./.ci/before_script.sh + - vendor/bin/phpcs --standard=ruleset.xml PHPUnit/ script: "vendor/bin/phpunit Tests" diff --git a/PHPUnit/Extensions/Selenium2TestCase.php b/PHPUnit/Extensions/Selenium2TestCase.php index 95c35181..cf119969 100644 --- a/PHPUnit/Extensions/Selenium2TestCase.php +++ b/PHPUnit/Extensions/Selenium2TestCase.php @@ -1,50 +1,17 @@ . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. +/* + * This file is part of PHPUnit. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * (c) Sebastian Bergmann * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://www.phpunit.de/ - * @since File available since Release 1.2.0 + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace PHPUnit\Extensions; use Exception; +use InvalidArgumentException; use PHPUnit\Extensions\Selenium2TestCase\Element; use PHPUnit\Extensions\Selenium2TestCase\Element\Select; use PHPUnit\Extensions\Selenium2TestCase\ElementCriteria; @@ -59,7 +26,6 @@ use PHPUnit\Extensions\Selenium2TestCase\WaitUntil; use PHPUnit\Extensions\Selenium2TestCase\Window; use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage; -use PHPUnit\Framework\InvalidArgumentException; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestResult; use RuntimeException; @@ -70,13 +36,6 @@ * (WebDriver API and JsonWire protocol) to provide * the functionality required for web testing. * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ - * @since Class available since Release 1.2.0 * @method void acceptAlert() Press OK on an alert, or confirms a dialog * @method mixed alertText() alertText($value = NULL) Gets the alert dialog text, or sets the text for a prompt dialog * @method void back() @@ -121,31 +80,22 @@ */ abstract class Selenium2TestCase extends TestCase { - const VERSION = '9.0.0'; - /** - * @var string override to provide code coverage data from the server - */ + public const VERSION = '9.0.0'; + + /** @var string override to provide code coverage data from the server */ protected $coverageScriptUrl; - /** - * @var Session - */ + /** @var Session */ private $session; - /** - * @var array - */ + /** @var array */ private $parameters; - /** - * @var SessionStrategy - */ + /** @var SessionStrategy */ protected static $sessionStrategy; - /** - * @var SessionStrategy - */ + /** @var SessionStrategy */ protected static $browserSessionStrategy; /** @@ -162,132 +112,111 @@ abstract class Selenium2TestCase extends TestCase */ private static $defaultWaitUntilSleepInterval = 500; - /** - * @var SessionStrategy - */ + /** @var SessionStrategy */ protected $localSessionStrategy; - /** - * @var array - */ + /** @var array */ private static $lastBrowserParams; - /** - * @var string - */ + /** @var string */ private $testId; - /** - * @var boolean - */ + /** @var bool */ private $collectCodeCoverageInformation; - /** - * @var KeysHolder - */ + /** @var KeysHolder */ private $keysHolder; - /** - * @param boolean - */ - private static $keepSessionOnFailure = FALSE; + /** @param boolean */ + private static $keepSessionOnFailure = false; - /** - * @param boolean - */ - public static function shareSession($shareSession) + public static function shareSession(bool $shareSession): void { - if (!is_bool($shareSession)) { - throw new \InvalidArgumentException("The shared session support can only be switched on or off."); - } - if (!$shareSession) { + if (! $shareSession) { self::$sessionStrategy = self::defaultSessionStrategy(); } else { self::$sessionStrategy = new Shared( - self::defaultSessionStrategy(), self::$keepSessionOnFailure - ); + self::defaultSessionStrategy(), + self::$keepSessionOnFailure + ); } } - public static function keepSessionOnFailure($keepSession) + public static function keepSessionOnFailure(bool $keepSession): void { - if (!is_bool($keepSession)) { - throw new \InvalidArgumentException("The keep session on fail support can only be switched on or off."); + if ($keepSession) { + self::$keepSessionOnFailure = true; } - if ($keepSession){ - self::$keepSessionOnFailure = TRUE; - } } - private static function sessionStrategy() + private static function sessionStrategy(): SessionStrategy { - if (!self::$sessionStrategy) { + if (! self::$sessionStrategy) { self::$sessionStrategy = self::defaultSessionStrategy(); } + return self::$sessionStrategy; } - private static function defaultSessionStrategy() + private static function defaultSessionStrategy(): SessionStrategy { - return new Isolated; + return new Isolated(); } /** * Get the default timeout for WaitUntil - * @return int the default timeout */ - public static function defaultWaitUntilTimeout(){ + public static function defaultWaitUntilTimeout(): int + { return self::$defaultWaitUntilTimeout; } /** * Set the default timeout for WaitUntil - * @param int $timeout the new default timeout */ - public static function setDefaultWaitUntilTimeout($timeout){ - $timeout = (int) $timeout; + public static function setDefaultWaitUntilTimeout(int $timeout): void + { self::$defaultWaitUntilTimeout = $timeout > 0 ? $timeout : 0; } /** * Get the default sleep delay for WaitUntil - * @return int */ - public static function defaultWaitUntilSleepInterval(){ + public static function defaultWaitUntilSleepInterval(): int + { return self::$defaultWaitUntilSleepInterval; } /** * Set default sleep delay for WaitUntil - * @param int $sleepDelay the new default sleep delay */ - public static function setDefaultWaitUntilSleepInterval($sleepDelay){ - $sleepDelay = (int) $sleepDelay; + public static function setDefaultWaitUntilSleepInterval(int $sleepDelay): void + { self::$defaultWaitUntilSleepInterval = $sleepDelay > 0 ? $sleepDelay : 0; } - - public function __construct($name = NULL, array $data = array(), $dataName = '') + public function __construct($name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); - $this->parameters = array( + $this->parameters = [ 'host' => 'localhost', 'port' => 4444, - 'browser' => NULL, - 'browserName' => NULL, - 'desiredCapabilities' => array(), + 'browser' => null, + 'browserName' => null, + 'desiredCapabilities' => [], 'seleniumServerRequestsTimeout' => 60, - 'secure' => FALSE - ); + 'secure' => false, + ]; $this->keysHolder = new KeysHolder(); } - public function setupSpecificBrowser($params) + public function setupSpecificBrowser(array $params): void { if (isset($params['keepSession'])) { - $this->keepSessionOnFailure(TRUE); + $this->keepSessionOnFailure(true); } + $this->setUpSessionStrategy($params); $params = array_merge($this->parameters, $params); $this->setHost($params['host']); @@ -296,36 +225,38 @@ public function setupSpecificBrowser($params) $this->parameters['browser'] = $params['browser']; $this->setDesiredCapabilities($params['desiredCapabilities']); $this->setSeleniumServerRequestsTimeout( - $params['seleniumServerRequestsTimeout']); + $params['seleniumServerRequestsTimeout'] + ); } - protected function setUpSessionStrategy($params) + protected function setUpSessionStrategy(array $params): void { // This logic enables us to have a session strategy reused for each // item in self::$browsers. We don't want them both to share one // and we don't want each test for a specific browser to have a // new strategy - if ($params == self::$lastBrowserParams) { - // do nothing so we use the same session strategy for this - // browser + + // phpcs:disable Generic.CodeAnalysis.EmptyStatement + if ($params === self::$lastBrowserParams) { + // do nothing so we use the same session strategy for this browser } elseif (isset($params['sessionStrategy'])) { $strat = $params['sessionStrategy']; - if ($strat != "isolated" && $strat != "shared") { - throw new \InvalidArgumentException("Session strategy must be either 'isolated' or 'shared'"); - } elseif ($strat == "isolated") { - self::$browserSessionStrategy = new Isolated; + if ($strat !== 'isolated' && $strat !== 'shared') { + throw new InvalidArgumentException("Session strategy must be either 'isolated' or 'shared'"); + } elseif ($strat === 'isolated') { + self::$browserSessionStrategy = new Isolated(); } else { self::$browserSessionStrategy = new Shared(self::defaultSessionStrategy(), self::$keepSessionOnFailure); } } else { self::$browserSessionStrategy = self::defaultSessionStrategy(); } - self::$lastBrowserParams = $params; - $this->localSessionStrategy = self::$browserSessionStrategy; + self::$lastBrowserParams = $params; + $this->localSessionStrategy = self::$browserSessionStrategy; } - private function getStrategy() + private function getStrategy(): SessionStrategy { if ($this->localSessionStrategy) { return $this->localSessionStrategy; @@ -334,23 +265,24 @@ private function getStrategy() } } - public function prepareSession() + public function prepareSession(): Session { try { - if (!$this->session) { + if (! $this->session) { $this->session = $this->getStrategy()->session($this->parameters); } } catch (NoSeleniumException $e) { - $this->markTestSkipped("The Selenium Server is not active on host {$this->parameters['host']} at port {$this->parameters['port']}."); + $this->markTestSkipped(sprintf('The Selenium Server is not active on host %s at port %s.', $this->parameters['host'], $this->parameters['port'])); } + return $this->session; } - public function run(TestResult $result = NULL): TestResult + public function run(?TestResult $result = null): TestResult { - $this->testId = get_class($this) . '__' . $this->getName(); + $this->testId = static::class . '__' . $this->getName(); - if ($result === NULL) { + if ($result === null) { $result = $this->createResult(); } @@ -364,7 +296,8 @@ public function run(TestResult $result = NULL): TestResult $this->testId ); $result->getCodeCoverage()->append( - $coverage->get(), $this + $coverage->get(), + $this ); } @@ -382,7 +315,7 @@ protected function runTest() { $this->prepareSession(); - $thrownException = NULL; + $thrownException = null; if ($this->collectCodeCoverageInformation) { $this->url($this->coverageScriptUrl); // phpunit_coverage.php won't do anything if the cookie isn't set, which is exactly what we want @@ -393,7 +326,7 @@ protected function runTest() $this->setUpPage(); $result = parent::runTest(); - if (!empty($this->verificationErrors)) { + if (! empty($this->verificationErrors)) { $this->fail(implode("\n", $this->verificationErrors)); } } catch (Exception $e) { @@ -404,15 +337,17 @@ protected function runTest() $this->session->cookie()->remove('PHPUNIT_SELENIUM_TEST_ID'); } - if (NULL !== $thrownException) { + if ($thrownException !== null) { throw $thrownException; } return $result; } - - public static function suite($className) + /** + * @return SeleniumTestSuite + */ + public static function suite(string $className) { return SeleniumTestSuite::fromTestCaseClass($className); } @@ -428,183 +363,137 @@ public function onNotSuccessfulTest(Throwable $e): void * * @param string $command * @param array $arguments + * * @return mixed */ public function __call($command, $arguments) { - if ($this->session === NULL) { - throw new \PHPUnit\Extensions\Selenium2TestCase\Exception("There is currently no active session to execute the '$command' command. You're probably trying to set some option in setUp() with an incorrect setter name. You may consider using setUpPage() instead."); + if ($this->session === null) { + throw new \PHPUnit\Extensions\Selenium2TestCase\Exception(sprintf("There is currently no active session to execute the '%s' command. You're probably trying to set some option in setUp() with an incorrect setter name. You may consider using setUpPage() instead.", $command)); } - $result = call_user_func_array( - array($this->session, $command), $arguments - ); - return $result; + return call_user_func_array( + [$this->session, $command], + $arguments + ); } - /** - * @param string $host - * @throws InvalidArgumentException - */ - public function setHost($host) + public function setHost(string $host): void { - if (!is_string($host)) { - throw InvalidArgumentException::create(1, 'string'); - } - $this->parameters['host'] = $host; } - public function getHost() + public function getHost(): string { return $this->parameters['host']; } - /** - * @param integer $port - * @throws InvalidArgumentException - */ - public function setPort($port) + public function setPort(int $port): void { - if (!is_int($port)) { - throw InvalidArgumentException::create(1, 'integer'); - } - $this->parameters['port'] = $port; } - public function getPort() + public function getPort(): int { return $this->parameters['port']; } - /** - * @param boolean $secure - * @throws InvalidArgumentException - */ - public function setSecure($secure) + public function setSecure(bool $secure): void { - if(!is_bool($secure)) { - throw InvalidArgumentException::create(1, 'boolean'); - } - $this->parameters['secure'] = $secure; } - public function getSecure() + public function getSecure(): bool { return $this->parameters['secure']; } - /** - * @param string $browser - * @throws InvalidArgumentException - */ - public function setBrowser($browserName) + public function setBrowser(string $browserName): void { - if (!is_string($browserName)) { - throw InvalidArgumentException::create(1, 'string'); - } - $this->parameters['browserName'] = $browserName; } - public function getBrowser() + public function getBrowser(): string { return $this->parameters['browserName']; } - /** - * @param string $browserUrl - * @throws InvalidArgumentException - */ - public function setBrowserUrl($browserUrl) + public function setBrowserUrl(string $browserUrl): void { - if (!is_string($browserUrl)) { - throw InvalidArgumentException::create(1, 'string'); - } - $this->parameters['browserUrl'] = new URL($browserUrl); } - public function getBrowserUrl() + public function getBrowserUrl(): string { - if (isset($this->parameters['browserUrl'])) { - return $this->parameters['browserUrl']; - } - return ''; + return $this->parameters['browserUrl'] ?? ''; } /** * @see http://code.google.com/p/selenium/wiki/JsonWireProtocol */ - public function setDesiredCapabilities(array $capabilities) + public function setDesiredCapabilities(array $capabilities): void { $this->parameters['desiredCapabilities'] = $capabilities; } - - public function getDesiredCapabilities() + public function getDesiredCapabilities(): array { return $this->parameters['desiredCapabilities']; } - /** - * @param int $timeout seconds - */ - public function setSeleniumServerRequestsTimeout($timeout) + public function setSeleniumServerRequestsTimeout(int $timeout): void { $this->parameters['seleniumServerRequestsTimeout'] = $timeout; } - public function getSeleniumServerRequestsTimeout() + public function getSeleniumServerRequestsTimeout(): int { return $this->parameters['seleniumServerRequestsTimeout']; } /** * Get test id (generated internally) - * @return string */ - public function getTestId() + public function getTestId(): string { return $this->testId; } /** * Get Selenium2 current session id - * @return string */ - public function getSessionId() + public function getSessionId(): string { if ($this->session) { return $this->session->id(); } - return FALSE; + + return false; } /** * Wait until callback isn't null or timeout occurs * - * @param $callback - * @param null $timeout * @return mixed */ - public function waitUntil($callback, $timeout = NULL) + public function waitUntil($callback, $timeout = null) { $waitUntil = new WaitUntil($this); + return $waitUntil->run($callback, $timeout); } /** * Sends a special key * Deprecated due to issues with IE webdriver. Use keys() method instead + * * @deprecated - * @param string $name - * @throws \PHPUnit\Extensions\Selenium2TestCase\Exception + * * @see KeysHolder + * + * @throws \PHPUnit\Extensions\Selenium2TestCase\Exception */ - public function keysSpecial($name) + public function keysSpecial(string $name): void { $names = explode(',', $name); @@ -619,19 +508,21 @@ public function keysSpecial($name) */ public function setUpPage() { - } /** * Check whether an alert box is present + * + * @return true|null */ public function alertIsPresent() { try { $this->alertText(); - return TRUE; + + return true; } catch (Exception $e) { - return NULL; + return null; } } } diff --git a/PHPUnit/Extensions/Selenium2TestCase/Command.php b/PHPUnit/Extensions/Selenium2TestCase/Command.php index 033b641e..fcf16b2c 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/Command.php +++ b/PHPUnit/Extensions/Selenium2TestCase/Command.php @@ -1,45 +1,11 @@ . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. +/* + * This file is part of PHPUnit. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * (c) Sebastian Bergmann * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://www.phpunit.de/ - * @since File available since Release 1.2.0 + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace PHPUnit\Extensions\Selenium2TestCase; @@ -48,45 +14,32 @@ /** * Base class for implementing commands with special semantics. - * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ - * @since Class available since Release 1.2.0 */ abstract class Command { protected $jsonParameters; - private $commandName; + private $url; /** - * @param array $jsonParameters null in case of no parameters + * @param array $jsonParameters null in case of no parameters */ - public function __construct($jsonParameters, URL $url) + public function __construct(?array $jsonParameters, URL $url) { - if (!is_array($jsonParameters) && $jsonParameters !== NULL) { - throw new InvalidArgumentException("The JSON parameters must be an array, or a NULL value in case they are not required."); + if (! is_array($jsonParameters) && $jsonParameters !== null) { + throw new InvalidArgumentException('The JSON parameters must be an array, or a NULL value in case they are not required.'); } + $this->jsonParameters = $jsonParameters; - $this->url = $url; + $this->url = $url; } - public function url() + public function url(): URL { return $this->url; } - /** - * @return string - */ - abstract public function httpMethod(); + abstract public function httpMethod(): string; - /** - * @param array $jsonParameters null in case of no parameters - */ public function jsonParameters() { return $this->jsonParameters; diff --git a/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php b/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php index 1f7c56dd..99c6cd42 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php +++ b/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php @@ -1,45 +1,11 @@ . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. +/* + * This file is part of PHPUnit. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * (c) Sebastian Bergmann * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://www.phpunit.de/ - * @since File available since Release 1.2.4 + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace PHPUnit\Extensions\Selenium2TestCase; @@ -50,92 +16,80 @@ /** * Object representing elements, or everything that may have subcommands. - * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ - * @since Class available since Release 1.2.4 */ abstract class CommandsHolder { - /** - * @var Driver - */ + /** @var Driver */ protected $driver; - /** - * @var string the API URL for this element, - */ + /** @var string the API URL for this element, */ protected $url; - /** - * @var array instances of - * PHPUnit_Extensions_Selenium2TestCase_ElementCommand - */ + /** @var array instances of PHPUnit_Extensions_Selenium2TestCase_ElementCommand */ protected $commands; - public function __construct($driver, URL $url) + public function __construct(Driver $driver, URL $url) { - $this->driver = $driver; - $this->url = $url; - $this->commands = array(); + $this->driver = $driver; + $this->url = $url; + $this->commands = []; foreach ($this->initCommands() as $commandName => $handler) { if (is_string($handler)) { $this->commands[$commandName] = $this->factoryMethod($handler); - } else if (is_callable($handler)) { + } elseif (is_callable($handler)) { $this->commands[$commandName] = $handler; } else { - throw new InvalidArgumentException("Command $commandName is not configured correctly."); + throw new InvalidArgumentException(sprintf('Command %s is not configured correctly.', $commandName)); } } } /** - * @return array class names, or - * callables of the form function($parameter, $commandUrl) + * @return array class names, or callables of the form function($parameter, $commandUrl) */ - protected abstract function initCommands(); + abstract protected function initCommands(): array; public function __call($commandName, $arguments) { $jsonParameters = $this->extractJsonParameters($arguments); - $response = $this->driver->execute($this->newCommand($commandName, $jsonParameters)); + $response = $this->driver->execute($this->newCommand($commandName, $jsonParameters)); + return $response->getValue(); } - protected function postCommand($name, ElementCriteria $criteria) + protected function postCommand(string $name, ElementCriteria $criteria) { - $response = $this->driver->curl('POST', - $this->url->addCommand($name), - $criteria->getArrayCopy()); + $response = $this->driver->curl( + 'POST', + $this->url->addCommand($name), + $criteria->getArrayCopy() + ); + return $response->getValue(); } /** - * @params string $commandClass a class name, descending from Command - * @return callable + * @param string $commandClass a class name, descending from Command */ - private function factoryMethod($commandClass) + private function factoryMethod(string $commandClass): callable { - return function($jsonParameters, $url) use ($commandClass) { + return static function ($jsonParameters, $url) use ($commandClass) { return new $commandClass($jsonParameters, $url); }; } - private function extractJsonParameters($arguments) + private function extractJsonParameters(array $arguments) { $this->checkArguments($arguments); - if (count($arguments) == 0) { - return NULL; + if (count($arguments) === 0) { + return null; } + return $arguments[0]; } - private function checkArguments($arguments) + private function checkArguments(array $arguments): void { if (count($arguments) > 1) { throw new Exception('You cannot call a command with multiple method arguments.'); @@ -143,19 +97,18 @@ private function checkArguments($arguments) } /** - * @param string $commandName The called method name - * defined as a key in initCommands() - * @param array $jsonParameters - * @return Command + * @param string $commandName The called method name defined as a key in initCommands() + * @param string|array|null $jsonParameters */ - protected function newCommand($commandName, $jsonParameters) + protected function newCommand(string $commandName, $jsonParameters): Command { if (isset($this->commands[$commandName])) { $factoryMethod = $this->commands[$commandName]; - $url = $this->url->addCommand($commandName); - $command = $factoryMethod($jsonParameters, $url); - return $command; + $url = $this->url->addCommand($commandName); + + return $factoryMethod($jsonParameters, $url); } - throw new BadMethodCallException("The command '$commandName' is not existent or not supported yet."); + + throw new BadMethodCallException(sprintf("The command '%s' is not existent or not supported yet.", $commandName)); } } diff --git a/PHPUnit/Extensions/Selenium2TestCase/Driver.php b/PHPUnit/Extensions/Selenium2TestCase/Driver.php index 1ffc4587..8bc55406 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/Driver.php +++ b/PHPUnit/Extensions/Selenium2TestCase/Driver.php @@ -1,45 +1,11 @@ . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. +/* + * This file is part of PHPUnit. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * (c) Sebastian Bergmann * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://www.phpunit.de/ - * @since File available since Release 1.2.0 + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace PHPUnit\Extensions\Selenium2TestCase; @@ -49,14 +15,6 @@ /** * Driver for creating browser session with Selenium 2 (WebDriver API). - * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ - * @since Class available since Release 1.2.0 */ class Driver { @@ -65,23 +23,22 @@ class Driver public function __construct(URL $seleniumServerUrl, $timeout = 60) { - $this->seleniumServerUrl = $seleniumServerUrl; + $this->seleniumServerUrl = $seleniumServerUrl; $this->seleniumServerRequestsTimeout = $timeout; } - public function startSession(array $desiredCapabilities, URL $browserUrl) + public function startSession(array $desiredCapabilities, URL $browserUrl): Session { - $sessionCreation = $this->seleniumServerUrl->descend("/wd/hub/session"); - $response = $this->curl('POST', $sessionCreation, array( - 'desiredCapabilities' => $desiredCapabilities - )); - $sessionPrefix = $response->getURL(); + $sessionCreation = $this->seleniumServerUrl->descend('/wd/hub/session'); + $response = $this->curl('POST', $sessionCreation, ['desiredCapabilities' => $desiredCapabilities,]); + $sessionPrefix = $response->getURL(); $timeouts = new Timeouts( $this, $sessionPrefix->descend('timeouts'), $this->seleniumServerRequestsTimeout * 1000 ); + return new Session( $this, $sessionPrefix, @@ -93,31 +50,34 @@ public function startSession(array $desiredCapabilities, URL $browserUrl) /** * Performs an HTTP request to the Selenium 2 server. * - * @param string $method 'GET'|'POST'|'DELETE'|... + * @param string $method 'GET'|'POST'|'DELETE'|... * @param string $url - * @param array $params JSON parameters for POST requests + * @param array $params JSON parameters for POST requests */ - public function curl($http_method, URL $url, $params = NULL) + public function curl(string $httpMethod, URL $url, ?array $params = null): Response { $curl = curl_init($url->getValue()); curl_setopt($curl, CURLOPT_TIMEOUT, $this->seleniumServerRequestsTimeout); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($curl, - CURLOPT_HTTPHEADER, - array( - 'Content-type: application/json;charset=UTF-8', - 'Accept: application/json;charset=UTF-8' - )); - - if ($http_method === 'POST') { - curl_setopt($curl, CURLOPT_POST, TRUE); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt( + $curl, + CURLOPT_HTTPHEADER, + [ + 'Content-type: application/json;charset=UTF-8', + 'Accept: application/json;charset=UTF-8', + ] + ); + + if ($httpMethod === 'POST') { + curl_setopt($curl, CURLOPT_POST, true); if ($params && is_array($params)) { curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params)); } else { curl_setopt($curl, CURLOPT_POSTFIELDS, ''); } - curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); - } else if ($http_method == 'DELETE') { + + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + } elseif ($httpMethod === 'DELETE') { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); } @@ -125,27 +85,31 @@ public function curl($http_method, URL $url, $params = NULL) if (curl_errno($curl)) { throw new NoSeleniumException( 'Error connection[' . curl_errno($curl) . '] to ' . - $url->getValue() . ': ' . curl_error($curl) + $url->getValue() . ': ' . curl_error($curl) ); } + $info = curl_getinfo($curl); - if ($info['http_code'] == 0) { + if ($info['http_code'] === 0) { throw new NoSeleniumException(); } - if ($info['http_code'] == 404) { - throw new BadMethodCallException("The command $url is not recognized by the server."); + + if ($info['http_code'] === 404) { + throw new BadMethodCallException(sprintf('The command %s is not recognized by the server.', $url)); } + if (($info['http_code'] >= 400) && ($info['http_code'] < 500)) { - throw new BadMethodCallException("Something unexpected happened: '$rawResponse'"); + throw new BadMethodCallException(sprintf("Something unexpected happened: '%s'", $rawResponse)); } + curl_close($curl); - $content = json_decode($rawResponse, TRUE); + $content = json_decode($rawResponse, true); if ($content === null && json_last_error() !== JSON_ERROR_NONE) { throw new \PHPUnit\Extensions\Selenium2TestCase\Exception( sprintf( - "JSON decoding of remote response failed.\n". - "Error code: %d\n". + "JSON decoding of remote response failed.\n" . + "Error code: %d\n" . "The response: '%s'\n", json_last_error(), $rawResponse @@ -163,7 +127,7 @@ public function curl($http_method, URL $url, $params = NULL) $message = $value['message']; } - $status = isset($content['status']) ? $content['status'] : 0; + $status = $content['status'] ?? 0; if ($status !== WebDriverException::Success) { throw new WebDriverException($message, $status); } @@ -171,10 +135,12 @@ public function curl($http_method, URL $url, $params = NULL) return new Response($content, $info); } - public function execute(Command $command) + public function execute(Command $command): Response { - return $this->curl($command->httpMethod(), - $command->url(), - $command->jsonParameters()); + return $this->curl( + $command->httpMethod(), + $command->url(), + $command->jsonParameters() + ); } } diff --git a/PHPUnit/Extensions/Selenium2TestCase/Element.php b/PHPUnit/Extensions/Selenium2TestCase/Element.php index 5932b224..daa362e8 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/Element.php +++ b/PHPUnit/Extensions/Selenium2TestCase/Element.php @@ -1,45 +1,11 @@ . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. +/* + * This file is part of PHPUnit. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * (c) Sebastian Bergmann * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://www.phpunit.de/ - * @since File available since Release 1.2.0 + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace PHPUnit\Extensions\Selenium2TestCase; @@ -58,13 +24,6 @@ /** * Object representing a DOM element. * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ - * @since Class available since Release 1.2.0 * @method string attribute($name) Retrieves an element's attribute * @method void clear() Empties the content of a form element. * @method void click() Clicks on element @@ -82,32 +41,30 @@ class Element extends Accessor { /** - * @return \self * @throws InvalidArgumentException */ - public static function fromResponseValue(array $value, URL $parentFolder, Driver $driver) + public static function fromResponseValue(array $value, URL $parentFolder, Driver $driver): Element { - if (!isset($value['ELEMENT'])) { + if (! isset($value['ELEMENT'])) { throw new InvalidArgumentException('Element not found.'); } + $url = $parentFolder->descend($value['ELEMENT']); + return new self($driver, $url); } - /** - * @return integer - */ - public function getId() + public function getId(): int { return $this->url->lastSegment(); } /** - * @return array class names + * @return array class names */ - protected function initCommands() + protected function initCommands(): array { - return array( + return [ 'attribute' => Attribute::class, 'clear' => GenericPost::class, 'click' => Click::class, @@ -127,61 +84,58 @@ protected function initCommands() 'scroll' => $this->touchCommandFactoryMethod('touch/scroll'), 'doubletap' => $this->touchCommandFactoryMethod('touch/doubleclick'), 'longtap' => $this->touchCommandFactoryMethod('touch/longclick'), - 'flick' => $this->touchCommandFactoryMethod('touch/flick') - ); + 'flick' => $this->touchCommandFactoryMethod('touch/flick'), + ]; } - protected function getSessionUrl() + protected function getSessionUrl(): URL { return $this->url->ascend()->ascend(); } - private function touchCommandFactoryMethod($urlSegment) + private function touchCommandFactoryMethod(string $urlSegment): callable { - $url = $this->getSessionUrl()->addCommand($urlSegment); + $url = $this->getSessionUrl()->addCommand($urlSegment); $self = $this; - return function ($jsonParameters, $commandUrl) use ($url, $self) { + + return static function ($jsonParameters, $commandUrl) use ($url, $self) { if ((is_array($jsonParameters) && - !isset($jsonParameters['element'])) || - is_null($jsonParameters)) { + ! isset($jsonParameters['element'])) || + $jsonParameters === null) { $jsonParameters['element'] = $self->getId(); } + return new GenericPost($jsonParameters, $url); }; } /** * Retrieves the tag name - * @return string */ - public function name() + public function name(): string { return strtolower(parent::name()); } /** * Generates an array that is structured as the WebDriver Object of the JSONWireProtocoll - * - * @return array */ - public function toWebDriverObject() + public function toWebDriverObject(): array { - return array('ELEMENT' => (string)$this->getId()); + return ['ELEMENT' => (string) $this->getId()]; } /** * Get or set value of form elements. If the element already has a value, the set one will be appended to it. * Created **ONLY** for keeping backward compatibility, since in selenium v2.42.0 it was removed * The currently recommended solution is to use `$element->attribute('value')` + * * @see https://code.google.com/p/selenium/source/detail?r=953007b48e83f90450f3e41b11ec31e2928f1605 * @see https://code.google.com/p/selenium/source/browse/java/CHANGELOG - * - * @param string $newValue - * @return null|string */ - public function value($newValue = NULL) + public function value(?string $newValue = null): ?string { - if ($newValue !== NULL) { + if ($newValue !== null) { return parent::value($newValue); } diff --git a/PHPUnit/Extensions/Selenium2TestCase/Element/Accessor.php b/PHPUnit/Extensions/Selenium2TestCase/Element/Accessor.php index 6e87b125..9625026d 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/Element/Accessor.php +++ b/PHPUnit/Extensions/Selenium2TestCase/Element/Accessor.php @@ -1,43 +1,11 @@ . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. +/* + * This file is part of PHPUnit. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * (c) Sebastian Bergmann * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_Selenium - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://www.phpunit.de/ + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace PHPUnit\Extensions\Selenium2TestCase\Element; @@ -47,135 +15,108 @@ use PHPUnit\Extensions\Selenium2TestCase\ElementCriteria; use PHPUnit\Extensions\Selenium2TestCase\URL; - /** * Provides access to /element and /elements commands - * - * @package PHPUnit_Selenium - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @version Release: @package_version@ - * @link http://www.phpunit.de/ */ abstract class Accessor extends CommandsHolder { - /** - * @param string $value e.g. 'container' - * @return Element + * @param string $value e.g. 'container' */ - public function byClassName($value) + public function byClassName(string $value): Element { return $this->by('class name', $value); } /** - * @param string $value e.g. 'div.container' - * @return Element + * @param string $value e.g. 'div.container' */ - public function byCssSelector($value) + public function byCssSelector(string $value): Element { return $this->by('css selector', $value); } /** - * @param string $value e.g. 'uniqueId' - * @return Element + * @param string $value e.g. 'uniqueId' */ - public function byId($value) + public function byId(string $value): Element { return $this->by('id', $value); } /** - * @param string $value e.g. 'Link text' - * @return Element + * @param string $value e.g. 'Link text' */ - public function byLinkText($value) + public function byLinkText(string $value): Element { return $this->by('link text', $value); } /** - * @param string $value e.g. 'Link te' - * @return Element + * @param string $value e.g. 'Link te' */ - public function byPartialLinkText($value) + public function byPartialLinkText(string $value): Element { return $this->by('partial link text', $value); } /** - * @param string $value e.g. 'email_address' - * @return Element + * @param string $value e.g. 'email_address' */ - public function byName($value) + public function byName(string $value): Element { return $this->by('name', $value); } /** - * @param string $value e.g. 'body' - * @return Element + * @param string $value e.g. 'body' */ - public function byTag($value) + public function byTag(string $value): Element { return $this->by('tag name', $value); } /** - * @param string $value e.g. '/div[@attribute="value"]' - * @return Element + * @param string $value e.g. '/div[@attribute="value"]' */ - public function byXPath($value) + public function byXPath(string $value): Element { return $this->by('xpath', $value); } - /** - * @return Element - */ - public function element(ElementCriteria $criteria) + public function element(ElementCriteria $criteria): Element { $value = $this->postCommand('element', $criteria); + return Element::fromResponseValue($value, $this->getSessionUrl()->descend('element'), $this->driver); } /** * @return Element[] */ - public function elements(ElementCriteria $criteria) + public function elements(ElementCriteria $criteria): array { - $values = $this->postCommand('elements', $criteria); - $elements = array(); + $values = $this->postCommand('elements', $criteria); + $elements = []; foreach ($values as $value) { $elements[] = Element::fromResponseValue($value, $this->getSessionUrl()->descend('element'), $this->driver); } + return $elements; } - /** - * @param string $strategy - * @return ElementCriteria - */ - public function using($strategy) + public function using(string $strategy): ElementCriteria { return new ElementCriteria($strategy); } - /** - * @return URL - */ - protected abstract function getSessionUrl(); + abstract protected function getSessionUrl(): URL; /** - * @param string $strategy supported by JsonWireProtocol element/ command - * @param string $value - * @return Element + * @param string $strategy supported by JsonWireProtocol element/ command */ - private function by($strategy, $value) + private function by(string $strategy, string $value): Element { return $this->element($this->using($strategy)->value($value)); } - } diff --git a/PHPUnit/Extensions/Selenium2TestCase/Element/Select.php b/PHPUnit/Extensions/Selenium2TestCase/Element/Select.php index 3180a60d..d2c7d618 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/Element/Select.php +++ b/PHPUnit/Extensions/Selenium2TestCase/Element/Select.php @@ -1,45 +1,11 @@ . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. +/* + * This file is part of PHPUnit. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * (c) Sebastian Bergmann * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @package PHPUnit_Selenium - * @author Giorgio Sironi - * @copyright 2010-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://www.phpunit.de/ - * @since File available since Release 1.2.2 + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace PHPUnit\Extensions\Selenium2TestCase\Element; @@ -49,187 +15,172 @@ /** * Object representing a