diff --git a/.gitignore b/.gitignore index 4ec4fb47..f5817483 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .idea/ -!.idea/php.xml /vendor/ docker/.env \ No newline at end of file diff --git a/bin/behat b/bin/behat index fa653650..ec164261 100755 --- a/bin/behat +++ b/bin/behat @@ -20,11 +20,16 @@ register_shutdown_function('fatalHandler'); define('BEHAT_BIN_PATH', __FILE__); +/** + * Includes the specified file if it exists. + * + * @param string $file the file to include. + * @return mixed the value that the file returns. + */ function includeIfExists($file) { - if (file_exists($file)) { - return include $file; - } + /** @noinspection PhpIncludeInspection no way to inspect a dynamic include */ + return file_exists($file) ? include $file : false; } if (!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) { diff --git a/bin/containers b/bin/containers index 62e681ac..f0044ab5 100755 --- a/bin/containers +++ b/bin/containers @@ -14,6 +14,6 @@ else fi echo "Working on containers..." -docker-compose -p $PROJECT_NAME \ +docker-compose -p ${PROJECT_NAME} \ -f "$ROOT"/docker/docker-compose.yml \ "$@" diff --git a/dictionary.dic b/dictionary.dic index cd0fdf52..7eeb0dc2 100644 --- a/dictionary.dic +++ b/dictionary.dic @@ -1,6 +1,12 @@ colspan coords +getcsv keypress +Kudryashov +Lazarecki +Medology +screenshot +Serdyuk tbody tfoot thead diff --git a/src/Medology/Behat/Mink/FlexibleContext.php b/src/Medology/Behat/Mink/FlexibleContext.php index b3a5ea25..402f75fa 100644 --- a/src/Medology/Behat/Mink/FlexibleContext.php +++ b/src/Medology/Behat/Mink/FlexibleContext.php @@ -638,9 +638,10 @@ public function deleteCookie($key) * Attaches a local file to field with specified id|name|label|value. This is used when running behat and * browser session in different containers. * - * @When /^(?:|I )attach the local file "(?P[^"]*)" to "(?P(?:[^"]|\\")*)"$/ - * @param string $field The file field to select the file with - * @param string $path The local path of the file + * @When /^(?:|I )attach the local file "(?P[^"]*)" to "(?P(?:[^"]|\\")*)"$/ + * @param string $field The file field to select the file with + * @param string $path The local path of the file + * @throws UnsupportedDriverActionException if getWebDriverSession() is not supported by the current driver. */ public function addLocalFileToField($path, $field) { @@ -660,7 +661,13 @@ public function addLocalFileToField($path, $field) $zip->addFile($path, basename($path)); $zip->close(); - $remotePath = $this->getSession()->getDriver()->getWebDriverSession()->file([ + $driver = $this->getSession()->getDriver(); + if (!($driver instanceof Selenium2Driver)) { + throw new UnsupportedDriverActionException('getWebDriverSession() is not supported by %s', $driver); + } + + /** @noinspection PhpUndefinedMethodInspection file() method annotation is missing from WebDriver\Session */ + $remotePath = $driver->getWebDriverSession()->file([ 'file' => base64_encode(file_get_contents($tempZip)), ]); diff --git a/src/Medology/Behat/Mink/JavaScriptContext.php b/src/Medology/Behat/Mink/JavaScriptContext.php index c9d44dce..9aa08aaf 100644 --- a/src/Medology/Behat/Mink/JavaScriptContext.php +++ b/src/Medology/Behat/Mink/JavaScriptContext.php @@ -7,7 +7,7 @@ use Behat\Mink\Exception\ExpectationException; /** - * {@inheritdoc} + * Provides functionality modifying and checking the Javascript environment in the browser. */ class JavaScriptContext implements Context { diff --git a/src/Medology/Behat/ParallelWorker/Filter.php b/src/Medology/Behat/ParallelWorker/Filter.php index 53ce7e7a..12040194 100755 --- a/src/Medology/Behat/ParallelWorker/Filter.php +++ b/src/Medology/Behat/ParallelWorker/Filter.php @@ -11,7 +11,7 @@ use RuntimeException; /** - * A scenario filter which filters on individual scenarios and outlines. Usefull for separating tests onto multiple + * A scenario filter which filters on individual scenarios and outlines. Useful for separating tests onto multiple * worker nodes. * * Based on the behat-partial-runner (http://github.com/m00t/behat-partial-runner) by Anton Serdyuk (m00t). diff --git a/src/Medology/Behat/TypeCaster.php b/src/Medology/Behat/TypeCaster.php index 7fd7b5a6..927c981e 100644 --- a/src/Medology/Behat/TypeCaster.php +++ b/src/Medology/Behat/TypeCaster.php @@ -49,8 +49,8 @@ public function castStringToBool($string) * Casts a Quoted string to a string. * * This is helpful for when you want to write a step definition that - * accepts values that look like other scalar types, such as ints or - * bools. + * accepts values that look like other scalar types, such as int or + * bool. * * For example, if you wrote your step definition as follows: * diff --git a/tests/Behat/DefaultMocks/MagicMethods.php b/tests/Behat/DefaultMocks/MagicMethods.php index 1d9a1c4c..233a6a8c 100644 --- a/tests/Behat/DefaultMocks/MagicMethods.php +++ b/tests/Behat/DefaultMocks/MagicMethods.php @@ -26,5 +26,6 @@ public function __call($method, $arguments) public function __toString() { + return ''; } } diff --git a/tests/Medology/Behat/ParallelWorker/FilterTest.php b/tests/Medology/Behat/ParallelWorker/FilterTest.php index fd4c244c..a927eccf 100644 --- a/tests/Medology/Behat/ParallelWorker/FilterTest.php +++ b/tests/Medology/Behat/ParallelWorker/FilterTest.php @@ -19,7 +19,7 @@ public function testParallelWorkerFilter() // message check try { new Filter(-10, 10); - $this->expectException(InvalidArgumentException::class); + self::setExpectedException(InvalidArgumentException::class); } catch (Exception $e) { $this->assertEquals('Received bad arguments for ($curNode, $totalNodes): (-10, 10).', $e->getMessage()); } @@ -29,28 +29,28 @@ public function testParallelWorkerFilter() **************************/ try { new Filter(-1, 1); - $this->expectException(InvalidArgumentException::class); + self::setExpectedException(InvalidArgumentException::class); } catch (Exception $e) { $this->assertTrue($e instanceof InvalidArgumentException); } try { new Filter(0, 0); - $this->expectException(InvalidArgumentException::class); + self::setExpectedException(InvalidArgumentException::class); } catch (Exception $e) { $this->assertTrue($e instanceof InvalidArgumentException); } try { new Filter(-1, -1); - $this->expectException(InvalidArgumentException::class); + self::setExpectedException(InvalidArgumentException::class); } catch (Exception $e) { $this->assertTrue($e instanceof InvalidArgumentException); } try { new Filter(2, 1); - $this->expectException(InvalidArgumentException::class); + self::setExpectedException(InvalidArgumentException::class); } catch (Exception $e) { $this->assertTrue($e instanceof InvalidArgumentException); } @@ -105,12 +105,14 @@ public function testFeatureFilterDefaults() $this->assertEquals('Scenario#3', $scenarios[2]->getTitle()); $this->assertTrue($scenarios[2] instanceof OutlineNode); - $this->assertTrue($scenarios[2]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[2]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#1', 'outcome' => 'out#1'], ['action' => 'act#2', 'outcome' => 'out#2'], ['action' => 'act#3', 'outcome' => 'out#3'], - ], $scenarios[2]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); $this->assertEquals('Scenario#3 HD Remix', $scenarios[3]->getTitle()); } @@ -132,11 +134,13 @@ public function testFeatureFilterNodes2() $this->assertEquals('Scenario#3', $scenarios[1]->getTitle()); $this->assertTrue($scenarios[1] instanceof OutlineNode); - $this->assertTrue($scenarios[1]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[1]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#1', 'outcome' => 'out#1'], ['action' => 'act#3', 'outcome' => 'out#3'], - ], $scenarios[1]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); /***************** * Node 2 * @@ -150,10 +154,12 @@ public function testFeatureFilterNodes2() $this->assertEquals('Scenario#3', $scenarios[1]->getTitle()); $this->assertTrue($scenarios[1] instanceof OutlineNode); - $this->assertTrue($scenarios[1]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[1]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#2', 'outcome' => 'out#2'], - ], $scenarios[1]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); $this->assertEquals('Scenario#3 HD Remix', $scenarios[2]->getTitle()); } @@ -175,10 +181,12 @@ public function testFeatureFilterNodes3() $this->assertEquals('Scenario#3', $scenarios[1]->getTitle()); $this->assertTrue($scenarios[1] instanceof OutlineNode); - $this->assertTrue($scenarios[1]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[1]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#2', 'outcome' => 'out#2'], - ], $scenarios[1]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); /***************** * Node 2 * @@ -192,10 +200,12 @@ public function testFeatureFilterNodes3() $this->assertEquals('Scenario#3', $scenarios[1]->getTitle()); $this->assertTrue($scenarios[1] instanceof OutlineNode); - $this->assertTrue($scenarios[1]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[1]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#3', 'outcome' => 'out#3'], - ], $scenarios[1]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); /***************** * Node 3 * @@ -208,10 +218,12 @@ public function testFeatureFilterNodes3() $this->assertEquals('Scenario#3', $scenarios[0]->getTitle()); $this->assertTrue($scenarios[0] instanceof OutlineNode); - $this->assertTrue($scenarios[0]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[0]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#1', 'outcome' => 'out#1'], - ], $scenarios[0]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); $this->assertEquals('Scenario#3 HD Remix', $scenarios[1]->getTitle()); } @@ -233,10 +245,12 @@ public function testFeatureFilterNodes4() $this->assertEquals('Scenario#3', $scenarios[1]->getTitle()); $this->assertTrue($scenarios[1] instanceof OutlineNode); - $this->assertTrue($scenarios[1]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[1]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#3', 'outcome' => 'out#3'], - ], $scenarios[1]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); /***************** * Node 2 * @@ -260,10 +274,12 @@ public function testFeatureFilterNodes4() $this->assertEquals('Scenario#3', $scenarios[0]->getTitle()); $this->assertTrue($scenarios[0] instanceof OutlineNode); - $this->assertTrue($scenarios[0]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[0]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#1', 'outcome' => 'out#1'], - ], $scenarios[0]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); /***************** * Node 4 * @@ -276,9 +292,11 @@ public function testFeatureFilterNodes4() $this->assertEquals('Scenario#3', $scenarios[0]->getTitle()); $this->assertTrue($scenarios[0] instanceof OutlineNode); - $this->assertTrue($scenarios[0]->hasExamples()); + /** @var OutlineNode $outline */ + $outline = $scenarios[0]; + $this->assertTrue($outline->hasExamples()); $this->assertEquals([ ['action' => 'act#2', 'outcome' => 'out#2'], - ], $scenarios[0]->getExampleTable()->getColumnsHash()); + ], $outline->getExampleTable()->getColumnsHash()); } } diff --git a/tests/Medology/Behat/StoreContextTest.php b/tests/Medology/Behat/StoreContextTest.php index fd014c10..d855b265 100644 --- a/tests/Medology/Behat/StoreContextTest.php +++ b/tests/Medology/Behat/StoreContextTest.php @@ -7,7 +7,6 @@ use PHPUnit_Framework_Error; use PHPUnit_Framework_TestCase; use stdClass; -use TypeError; class StoreContextTest extends PHPUnit_Framework_TestCase { @@ -67,6 +66,7 @@ public function testInjectStoredValues() // test invalid argument for $string try { + /* @noinspection PhpParamsInspection intentional wrong argument type */ $this->storeContext->injectStoredValues([]); $this->setExpectedException('PHPUnit_Framework_Error_Warning'); } catch (Exception $e) { @@ -174,7 +174,8 @@ public function testInjectStoredValues() } // test function with no return - $badFn = function ($a) { + $badFn = function (/* @noinspection PhpUnusedParameterInspection */ $a) { + /** @noinspection PhpUnusedLocalVariableInspection */ $a = 1; }; @@ -187,7 +188,7 @@ public function testInjectStoredValues() } // test function with bad return - $badFn = function ($a) { + $badFn = function (/* @noinspection PhpUnusedParameterInspection */ $a) { return 'bad return'; }; @@ -199,7 +200,7 @@ public function testInjectStoredValues() $this->assertEquals('The $onGetFn method must return an object or an array!', $e->getMessage()); } - $badFn = function ($a) { + $badFn = function (/* @noinspection PhpUnusedParameterInspection */ $a) { return function () { }; }; @@ -221,7 +222,7 @@ public function testInjectStoredValues() $this->storeContext->injectStoredValues('(the test_property_1 of the testObj)', $goodFn) ); - // test accessing property after unsetting with callback + // test accessing property after un-setting with callback $goodFn = function ($thing) { unset($thing->test_property_1); @@ -298,10 +299,10 @@ function ($a, $b, $c) { $wrongReturnTypes = [ function ($a, $b) { }, - function ($a, $b) { + function (/* @noinspection PhpUnusedParameterInspection */ $a, $b) { return ''; }, - function ($a, $b) { + function (/* @noinspection PhpUnusedParameterInspection */ $a, $b) { return function () { }; }, @@ -321,7 +322,7 @@ function ($a, $b) { $this->storeContext->injectStoredValues( '(the test_property_1 of the testObj)', null, - function ($a, $b) { + function (/* @noinspection PhpUnusedParameterInspection */ $a, $b) { return false; } ); diff --git a/web/button-disabled.html b/web/button-disabled.html index 78291cf0..0a18454c 100644 --- a/web/button-disabled.html +++ b/web/button-disabled.html @@ -8,7 +8,7 @@ document.getElementById("disabled-button").removeAttribute("disabled"); } function disableEnabledButton() { - document.getElementById("enabled-button").setAttribute("disabled", null); + document.getElementById("enabled-button").setAttribute("disabled", ''); } diff --git a/web/image-load-test.html b/web/image-load-test.html index ee73102d..00002c1d 100644 --- a/web/image-load-test.html +++ b/web/image-load-test.html @@ -16,7 +16,7 @@

Valid Image Link

Valid Image

Invalid (Broken) Image

- Invalid Image + Invalid Image diff --git a/web/page-load-delay.html b/web/page-load-delay.html index f241887a..c1cd3013 100644 --- a/web/page-load-delay.html +++ b/web/page-load-delay.html @@ -11,7 +11,7 @@ // delay the click for 2 seconds setTimeout(function() { - location = $("#sml_delay").attr('href'); + window.location = $("#sml_delay").attr('href'); }, 2000); return false; @@ -23,7 +23,7 @@ // delay the click for 7 seconds setTimeout(function() { - location = $("#big_delay").attr('href'); + window.location = $("#big_delay").attr('href'); }, 7000); return false;