From 57355e788c0200301be1a3165cacc62f60087f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20=C5=A0trba?= Date: Mon, 15 Jun 2020 16:22:04 +0200 Subject: [PATCH] Fix type hints to pass tests --- PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php | 2 +- .../Extensions/Selenium2TestCase/ScreenshotListener.php | 9 +++------ .../Extensions/Selenium2TestCase/SessionCommand/File.php | 1 - PHPUnit/Extensions/Selenium2TestCase/URL.php | 1 - 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php b/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php index 3c4d4344..99c6cd42 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php +++ b/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php @@ -97,7 +97,7 @@ private function checkArguments(array $arguments): void } /** - * @param string $commandName The called method name defined as a key in initCommands() + * @param string $commandName The called method name defined as a key in initCommands() * @param string|array|null $jsonParameters */ protected function newCommand(string $commandName, $jsonParameters): Command diff --git a/PHPUnit/Extensions/Selenium2TestCase/ScreenshotListener.php b/PHPUnit/Extensions/Selenium2TestCase/ScreenshotListener.php index 3fbfd268..56b37507 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/ScreenshotListener.php +++ b/PHPUnit/Extensions/Selenium2TestCase/ScreenshotListener.php @@ -43,18 +43,15 @@ public function addFailure(Test $test, AssertionFailedError $e, float $time): vo private function storeAScreenshot(Test $test): void { - if ($test instanceof Selenium2TestCase) - { + if ($test instanceof Selenium2TestCase) { $className = str_replace('\\', '_', get_class($test)); try { $file = $this->directory . '/' . $className . '__' . $test->getName() . '__' . date('Y-m-d\TH-i-s') . '.png'; - file_put_contents($file, $test->currentScreenshot()); + file_put_contents($file, $test->currentScreenshot()); } catch (\Exception $e) { $file = $this->directory . '/' . $className . '__' . $test->getName() . '__' . date('Y-m-d\TH-i-s') . '.txt'; - file_put_contents($file, "Screenshot generation doesn't work." . "\n" - . $e->getMessage() . "\n" - . $e->getTraceAsString()); + file_put_contents($file, sprintf("Screenshot generation doesn't work.\n%s\n%s", $e->getMessage(), $e->getTraceAsString())); } } } diff --git a/PHPUnit/Extensions/Selenium2TestCase/SessionCommand/File.php b/PHPUnit/Extensions/Selenium2TestCase/SessionCommand/File.php index 4b8b8127..3ea5132f 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/SessionCommand/File.php +++ b/PHPUnit/Extensions/Selenium2TestCase/SessionCommand/File.php @@ -40,7 +40,6 @@ public function __construct(string $argument, URL $url) $file = base64_encode($contents); - parent::__construct(['file' => $file], $url); unlink($zipfilePath); diff --git a/PHPUnit/Extensions/Selenium2TestCase/URL.php b/PHPUnit/Extensions/Selenium2TestCase/URL.php index 405afc96..768d822d 100644 --- a/PHPUnit/Extensions/Selenium2TestCase/URL.php +++ b/PHPUnit/Extensions/Selenium2TestCase/URL.php @@ -18,7 +18,6 @@ final class URL /** @var string */ private $value; - /** @param string $value */ public function __construct(string $value) { $this->value = $value;