@@ -5,9 +5,9 @@ |
||
| 5 | 5 | |
| 6 | 6 | require_once __DIR__ . "/../../functions.php"; |
| 7 | 7 | |
| 8 | -use MyTester\TestCase, |
|
| 9 | - MyTester\Environment, |
|
| 10 | - Nette\Utils\Finder; |
|
| 8 | +use MyTester\TestCase; |
|
| 9 | +use MyTester\Environment; |
|
| 10 | +use Nette\Utils\Finder; |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Tests Runner |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace MyTester\Bridges\NetteDI; |
| 5 | 5 | |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | 44 | static function autoload(string $class): void { |
| 45 | - foreach(static::$autoloader as $suit) { |
|
| 46 | - if($suit[0] === $class) { |
|
| 45 | + foreach (static::$autoloader as $suit) { |
|
| 46 | + if ($suit[0] === $class) { |
|
| 47 | 47 | require $suit[1]; |
| 48 | 48 | return; |
| 49 | 49 | } |
@@ -56,26 +56,26 @@ discard block |
||
| 56 | 56 | function execute(): bool { |
| 57 | 57 | $this->onExecute(); |
| 58 | 58 | $failed = false; |
| 59 | - foreach($this->suits as $suit) { |
|
| 59 | + foreach ($this->suits as $suit) { |
|
| 60 | 60 | $result = $suit->run(); |
| 61 | - if(!$result) { |
|
| 61 | + if (!$result) { |
|
| 62 | 62 | $failed = true; |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | Environment::printLine(""); |
| 66 | - foreach(Environment::getSkipped() as $skipped) { |
|
| 66 | + foreach (Environment::getSkipped() as $skipped) { |
|
| 67 | 67 | $reason = ""; |
| 68 | - if($skipped["reason"]) { |
|
| 68 | + if ($skipped["reason"]) { |
|
| 69 | 69 | $reason = ": {$skipped["reason"]}"; |
| 70 | 70 | } |
| 71 | 71 | Environment::printLine("Skipped {$skipped["name"]}$reason"); |
| 72 | 72 | } |
| 73 | - if($failed) { |
|
| 73 | + if ($failed) { |
|
| 74 | 74 | Environment::printLine("Failed"); |
| 75 | 75 | Environment::printLine(""); |
| 76 | 76 | $files = Finder::findFiles("*.errors")->in(\getTestsDirectory()); |
| 77 | - foreach($files as $name => $file) { |
|
| 78 | - Environment::printLine("--- ". substr($file->getBaseName(), 0, -7)); |
|
| 77 | + foreach ($files as $name => $file) { |
|
| 78 | + Environment::printLine("--- " . substr($file->getBaseName(), 0, -7)); |
|
| 79 | 79 | echo file_get_contents($name); |
| 80 | 80 | } |
| 81 | 81 | } else { |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | |
| 4 | 4 | namespace MyTester; |
| 5 | 5 | |
| 6 | -use Nette\Utils\Finder, |
|
| 7 | - Nette\Utils\FileSystem; |
|
| 6 | +use Nette\Utils\Finder; |
|
| 7 | +use Nette\Utils\FileSystem; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Automated tests runner |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace MyTester; |
| 5 | 5 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $suits = []; |
| 38 | 38 | $robot = new \Nette\Loaders\RobotLoader; |
| 39 | 39 | $tempDir = "$folder/temp/cache/Robot.Loader"; |
| 40 | - if(is_dir("$folder/_temp")) { |
|
| 40 | + if (is_dir("$folder/_temp")) { |
|
| 41 | 41 | $tempDir = "$folder/_temp/cache/Robot.Loader"; |
| 42 | 42 | } |
| 43 | 43 | FileSystem::createDir($tempDir); |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | $robot->rebuild(); |
| 48 | 48 | $robot->register(); |
| 49 | 49 | $classes = $robot->getIndexedClasses(); |
| 50 | - foreach($classes as $class => $file) { |
|
| 50 | + foreach ($classes as $class => $file) { |
|
| 51 | 51 | $rc = new \Nette\Reflection\ClassType($class); |
| 52 | - if(!$rc->isAbstract() AND $rc->isSubclassOf(TestCase::class)) { |
|
| 52 | + if (!$rc->isAbstract() AND $rc->isSubclassOf(TestCase::class)) { |
|
| 53 | 53 | $suits[] = [$rc->getName(), $file]; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -72,27 +72,27 @@ discard block |
||
| 72 | 72 | Environment::setup(); |
| 73 | 73 | Environment::printInfo(); |
| 74 | 74 | $failed = false; |
| 75 | - foreach($this->suits as $suit) { |
|
| 75 | + foreach ($this->suits as $suit) { |
|
| 76 | 76 | /** @var TestCase $suit */ |
| 77 | 77 | $suit = new $suit[0]; |
| 78 | 78 | $result = $suit->run(); |
| 79 | - if(!$result) { |
|
| 79 | + if (!$result) { |
|
| 80 | 80 | $failed = true; |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | Environment::printLine(""); |
| 84 | - foreach(Environment::getSkipped() as $skipped) { |
|
| 84 | + foreach (Environment::getSkipped() as $skipped) { |
|
| 85 | 85 | $reason = ""; |
| 86 | - if($skipped["reason"]) { |
|
| 86 | + if ($skipped["reason"]) { |
|
| 87 | 87 | $reason = ": {$skipped["reason"]}"; |
| 88 | 88 | } |
| 89 | 89 | Environment::printLine("Skipped {$skipped["name"]}$reason"); |
| 90 | 90 | } |
| 91 | - if($failed) { |
|
| 91 | + if ($failed) { |
|
| 92 | 92 | Environment::printLine("Failed"); |
| 93 | 93 | Environment::printLine(""); |
| 94 | 94 | $files = Finder::findFiles("*.errors")->in(\getTestsDirectory()); |
| 95 | - foreach($files as $name => $file) { |
|
| 95 | + foreach ($files as $name => $file) { |
|
| 96 | 96 | Environment::printLine("--- " . substr($file->getBaseName(), 0, -7)); |
| 97 | 97 | echo file_get_contents($name); |
| 98 | 98 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace MyTester\Bridges\NetteDI; |
| 5 | 5 | |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | $builder = $this->getContainerBuilder(); |
| 28 | 28 | $builder->addDefinition($this->prefix("runner")) |
| 29 | 29 | ->setClass(TestsRunner::class); |
| 30 | - if(!is_dir($config["folder"])) { |
|
| 30 | + if (!is_dir($config["folder"])) { |
|
| 31 | 31 | throw new \Exception("Invalid folder {$config["folder"]} for $this->name.folder"); |
| 32 | 32 | } |
| 33 | 33 | $tester = new \MyTester\Tester($config["folder"]); |
| 34 | 34 | $this->suits = $tester->getSuits(); |
| 35 | - foreach($this->suits as $index => $suit) { |
|
| 35 | + foreach ($this->suits as $index => $suit) { |
|
| 36 | 36 | $builder->addDefinition($this->prefix("test." . ($index + 1))) |
| 37 | 37 | ->setClass($suit[0]) |
| 38 | 38 | ->addTag(self::TAG); |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | $initialize->addBody('spl_autoload_extensions(spl_autoload_extensions() . ",.phpt"); |
| 52 | 52 | MyTester\Bridges\NetteDI\TestsRunner::$autoloader = ?; |
| 53 | 53 | spl_autoload_register(?);', [$this->suits, TestsRunner::class . "::autoload"]); |
| 54 | - foreach($container->findByTag(self::TAG) as $suit => $foo) { |
|
| 54 | + foreach ($container->findByTag(self::TAG) as $suit => $foo) { |
|
| 55 | 55 | $initialize->addBody('$runner->addSuit($this->getService(?));', [$suit]); |
| 56 | 56 | } |
| 57 | 57 | $onExecute = array_merge(['MyTester\Environment::setup', 'MyTester\Environment::printInfo'], $config["onExecute"]); |
| 58 | - foreach($onExecute as &$task) { |
|
| 59 | - if(!is_array($task)) { |
|
| 58 | + foreach ($onExecute as &$task) { |
|
| 59 | + if (!is_array($task)) { |
|
| 60 | 60 | $task = explode("::", $task); |
| 61 | - } elseif(substr($task[0], 0, 1) === "@") { |
|
| 61 | + } elseif (substr($task[0], 0, 1) === "@") { |
|
| 62 | 62 | $initialize->addBody('$runner->onExecute[] = [$this->getService(?), ?];', [substr($task[0], 1), $task[1]]); |
| 63 | 63 | continue; |
| 64 | 64 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace MyTester; |
| 5 | 5 | |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | static function tryAssertion($code, string $successText = "", string $failureText = ""): void { |
| 25 | 25 | $success = assert($code); |
| 26 | - if(Environment::getShouldFail()) { |
|
| 26 | + if (Environment::getShouldFail()) { |
|
| 27 | 27 | $success = !$success; |
| 28 | 28 | } |
| 29 | - if($success) { |
|
| 29 | + if ($success) { |
|
| 30 | 30 | $message = ($successText === "") ? "Assertion \"$code\" is true." : $successText; |
| 31 | 31 | } else { |
| 32 | 32 | $message = ($failureText === "") ? "Assertion \"$code\" is not true." : $failureText; |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | static function same($expected, $actual): void { |
| 45 | 45 | $success = ($expected == $actual); |
| 46 | - if(Environment::getShouldFail()) { |
|
| 46 | + if (Environment::getShouldFail()) { |
|
| 47 | 47 | $success = !$success; |
| 48 | 48 | } |
| 49 | - if($success) { |
|
| 49 | + if ($success) { |
|
| 50 | 50 | $message = "The value is $expected."; |
| 51 | 51 | } else { |
| 52 | 52 | $message = "The value is not $expected but $actual."; |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | * @return void |
| 114 | 114 | */ |
| 115 | 115 | static function contains($needle, $actual): void { |
| 116 | - if(!is_string($needle) AND !is_array($needle)) { |
|
| 116 | + if (!is_string($needle) AND !is_array($needle)) { |
|
| 117 | 117 | Environment::testResult("The variable is not string or array.", false); |
| 118 | - } elseif(is_string($actual)) { |
|
| 119 | - if($needle !== "" AND strpos($actual, $needle) !== FALSE) { |
|
| 118 | + } elseif (is_string($actual)) { |
|
| 119 | + if ($needle !== "" AND strpos($actual, $needle) !== FALSE) { |
|
| 120 | 120 | Environment::testResult("$needle is in the variable."); |
| 121 | 121 | } else { |
| 122 | 122 | Environment::testResult("$needle is not in the variable.", false); |
| 123 | 123 | } |
| 124 | - } elseif(is_array($actual)) { |
|
| 125 | - if(in_array($needle, $actual)) { |
|
| 124 | + } elseif (is_array($actual)) { |
|
| 125 | + if (in_array($needle, $actual)) { |
|
| 126 | 126 | Environment::testResult("$needle is in the variable."); |
| 127 | 127 | } else { |
| 128 | 128 | Environment::testResult("$needle is not in the variable.", false); |
@@ -140,16 +140,16 @@ discard block |
||
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | 142 | static function notContains($needle, $actual): void { |
| 143 | - if(!is_string($needle) AND !is_array($needle)) { |
|
| 143 | + if (!is_string($needle) AND !is_array($needle)) { |
|
| 144 | 144 | Environment::testResult("The variable is not string or array.", false); |
| 145 | - } elseif(is_string($actual)) { |
|
| 146 | - if($needle === "" OR strpos($actual, $needle) === FALSE) { |
|
| 145 | + } elseif (is_string($actual)) { |
|
| 146 | + if ($needle === "" OR strpos($actual, $needle) === FALSE) { |
|
| 147 | 147 | Environment::testResult("$needle is not in the variable."); |
| 148 | 148 | } else { |
| 149 | 149 | Environment::testResult("$needle is in the variable.", false); |
| 150 | 150 | } |
| 151 | - } elseif(is_array($actual)) { |
|
| 152 | - if(!in_array($needle, $actual)) { |
|
| 151 | + } elseif (is_array($actual)) { |
|
| 152 | + if (!in_array($needle, $actual)) { |
|
| 153 | 153 | Environment::testResult("$needle is not in the variable."); |
| 154 | 154 | } else { |
| 155 | 155 | Environment::testResult("$needle is in the variable.", false); |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | * @return void |
| 168 | 168 | */ |
| 169 | 169 | static function count(int $count, $value): void { |
| 170 | - if(!is_array($value) AND !$value instanceof \Countable) { |
|
| 170 | + if (!is_array($value) AND !$value instanceof \Countable) { |
|
| 171 | 171 | Environment::testResult("The variable is not array or countable object.", false); |
| 172 | - } elseif(count($value) == $count) { |
|
| 172 | + } elseif (count($value) == $count) { |
|
| 173 | 173 | Environment::testResult("Count of the variable is $count."); |
| 174 | 174 | } else { |
| 175 | 175 | $actual = count($value); |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | * @return void |
| 186 | 186 | */ |
| 187 | 187 | static function notCount(int $count, $value): void { |
| 188 | - if(!is_array($value) AND !$value instanceof \Countable) { |
|
| 188 | + if (!is_array($value) AND !$value instanceof \Countable) { |
|
| 189 | 189 | Environment::testResult("The variable is not array or countable object.", false); |
| 190 | - } elseif(count($value) == $count) { |
|
| 190 | + } elseif (count($value) == $count) { |
|
| 191 | 191 | $actual = count($value); |
| 192 | 192 | Environment::testResult("Count of the variable is $actual.", false); |
| 193 | 193 | } else { |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | * @return void |
| 204 | 204 | */ |
| 205 | 205 | static function type($type, $value): void { |
| 206 | - if(!is_object($type) AND !is_string($type)) { |
|
| 206 | + if (!is_object($type) AND !is_string($type)) { |
|
| 207 | 207 | Environment::testResult("Type must be string or object.", false); |
| 208 | - } elseif(in_array($type, ["array", "bool", "callable", "float", |
|
| 208 | + } elseif (in_array($type, ["array", "bool", "callable", "float", |
|
| 209 | 209 | "int", "integer", "null", "object", "resource", "scalar", "string"], true)) { |
| 210 | - if(!call_user_func("is_$type", $value)) { |
|
| 210 | + if (!call_user_func("is_$type", $value)) { |
|
| 211 | 211 | Environment::testResult("The variable is " . gettype($value) . ".", false); |
| 212 | 212 | } else { |
| 213 | 213 | Environment::testResult("The variable is $type."); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace MyTester; |
| 5 | 5 | |
@@ -22,37 +22,37 @@ discard block |
||
| 22 | 22 | * @return bool|string |
| 23 | 23 | */ |
| 24 | 24 | protected function checkSkip(\Nette\Reflection\Method $method) { |
| 25 | - if(!$method->hasAnnotation("skip")) { |
|
| 25 | + if (!$method->hasAnnotation("skip")) { |
|
| 26 | 26 | return false; |
| 27 | 27 | } |
| 28 | 28 | $value = $method->getAnnotation("skip"); |
| 29 | - if(is_scalar($value)) { |
|
| 29 | + if (is_scalar($value)) { |
|
| 30 | 30 | return (bool) $value; |
| 31 | - } elseif($value instanceof \Nette\Utils\ArrayHash) { |
|
| 31 | + } elseif ($value instanceof \Nette\Utils\ArrayHash) { |
|
| 32 | 32 | $skip = false; |
| 33 | 33 | $reason = ""; |
| 34 | - foreach($value as $k => $v) { |
|
| 34 | + foreach ($value as $k => $v) { |
|
| 35 | 35 | switch ($k) { |
| 36 | 36 | case "php": |
| 37 | 37 | $skip = version_compare(PHP_VERSION, (string) $v, "<"); |
| 38 | - if($skip) { |
|
| 38 | + if ($skip) { |
|
| 39 | 39 | $reason = "PHP version is lesser than $v"; |
| 40 | 40 | } |
| 41 | 41 | break; |
| 42 | 42 | case "extension": |
| 43 | 43 | $skip = !extension_loaded($v); |
| 44 | - if($skip) { |
|
| 44 | + if ($skip) { |
|
| 45 | 45 | $reason = "extension $v is not loaded"; |
| 46 | 46 | } |
| 47 | 47 | break; |
| 48 | 48 | case "sapi": |
| 49 | 49 | $skip = PHP_SAPI != $v; |
| 50 | - if($skip) { |
|
| 50 | + if ($skip) { |
|
| 51 | 51 | $reason = "the sapi is not $v"; |
| 52 | 52 | } |
| 53 | 53 | break; |
| 54 | 54 | } |
| 55 | - if($skip) { |
|
| 55 | + if ($skip) { |
|
| 56 | 56 | return $reason; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | $methods = array_values(preg_grep(static::METHOD_PATTERN, array_map(function(\ReflectionMethod $rm) { |
| 72 | 72 | return $rm->getName(); |
| 73 | 73 | }, $r->getMethods()))); |
| 74 | - foreach($methods as $method) { |
|
| 74 | + foreach ($methods as $method) { |
|
| 75 | 75 | $rm = $r->getMethod($method); |
| 76 | 76 | $data = NULL; |
| 77 | 77 | $job = [ |
| 78 | 78 | "name" => $this->getJobName($rm), "callback" => [$this, $method], "params" => [], "skip" => $this->checkSkip($rm), "shouldFail" => $rm->hasAnnotation("fail") |
| 79 | 79 | ]; |
| 80 | - if($rm->getNumberOfParameters() AND $rm->hasAnnotation("data")) { |
|
| 80 | + if ($rm->getNumberOfParameters() AND $rm->hasAnnotation("data")) { |
|
| 81 | 81 | $data = (array) $rm->getAnnotation("data"); |
| 82 | 82 | } |
| 83 | - if(is_array($data)) { |
|
| 84 | - foreach($data as $value) { |
|
| 83 | + if (is_array($data)) { |
|
| 84 | + foreach ($data as $value) { |
|
| 85 | 85 | $job["params"][0] = $value; |
| 86 | 86 | $jobs[] = new Job($job["name"], $job["callback"], $job["params"], $job["skip"], $job["shouldFail"]); |
| 87 | 87 | $job["params"] = []; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | protected function getSuitName(): string { |
| 102 | 102 | $suitName = get_class($this); |
| 103 | 103 | $r = new \Nette\Reflection\ClassType($suitName); |
| 104 | - if($r->hasAnnotation("testSuit")) { |
|
| 104 | + if ($r->hasAnnotation("testSuit")) { |
|
| 105 | 105 | $suitName = (string) $r->getAnnotation("testSuit"); |
| 106 | 106 | } |
| 107 | 107 | return $suitName; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @return string |
| 115 | 115 | */ |
| 116 | 116 | protected function getJobName(\Nette\Reflection\Method $method): string { |
| 117 | - if($method->hasAnnotation("test")) { |
|
| 117 | + if ($method->hasAnnotation("test")) { |
|
| 118 | 118 | return (string) $method->getAnnotation("test"); |
| 119 | 119 | } |
| 120 | 120 | return $this->getSuitName() . "::" . $method->getName(); |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | protected function runJob(Job $job): string { |
| 164 | 164 | $jobName = $this->getJobName(\Nette\Reflection\Method::from($job->callback[0], $job->callback[1])); |
| 165 | 165 | Environment::$currentJob = $jobName; |
| 166 | - if(!$job->skip) { |
|
| 166 | + if (!$job->skip) { |
|
| 167 | 167 | $this->setUp(); |
| 168 | 168 | } |
| 169 | 169 | $job->execute(); |
| 170 | - if(!$job->skip) { |
|
| 170 | + if (!$job->skip) { |
|
| 171 | 171 | $this->tearDown(); |
| 172 | 172 | } |
| 173 | 173 | Environment::$currentJob = ""; |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | $jobs = $this->getJobs(); |
| 196 | 196 | $output = ""; |
| 197 | 197 | $passed = true; |
| 198 | - foreach($jobs as $job) { |
|
| 198 | + foreach ($jobs as $job) { |
|
| 199 | 199 | $output .= $this->runJob($job); |
| 200 | - if($job->result === "failed") { |
|
| 200 | + if ($job->result === "failed") { |
|
| 201 | 201 | $passed = false; |
| 202 | 202 | } |
| 203 | 203 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace MyTester; |
| 5 | 5 | |
@@ -75,20 +75,20 @@ discard block |
||
| 75 | 75 | function execute(): void { |
| 76 | 76 | Environment::resetCounter(); |
| 77 | 77 | Environment::setShouldFail($this->shouldFail); |
| 78 | - if($this->skip) { |
|
| 78 | + if ($this->skip) { |
|
| 79 | 79 | $this->result = "skipped"; |
| 80 | 80 | Environment::addSkipped($this->name, (!is_bool($this->skip) ? $this->skip : "")); |
| 81 | 81 | } else { |
| 82 | 82 | ob_start(); |
| 83 | - if(isset($this->callback)) { |
|
| 83 | + if (isset($this->callback)) { |
|
| 84 | 84 | call_user_func_array($this->callback, $this->params); |
| 85 | 85 | } |
| 86 | 86 | $output = ob_get_clean(); |
| 87 | 87 | $failed = Environment::checkFailed($output); |
| 88 | - if($failed AND !$this->shouldFail) { |
|
| 88 | + if ($failed AND !$this->shouldFail) { |
|
| 89 | 89 | $this->result = "failed"; |
| 90 | 90 | } |
| 91 | - if(strlen($output) AND $this->result === "failed") { |
|
| 91 | + if (strlen($output) AND $this->result === "failed") { |
|
| 92 | 92 | file_put_contents(\getTestsDirectory() . "/$this->name.errors", $output); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | function findVendorDirectory(): string { |
| 5 | 5 | $recursionLimit = 10; |
| 6 | - $findVendor = function ($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) { |
|
| 6 | + $findVendor = function($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) { |
|
| 7 | 7 | if (!$recursionLimit--) { |
| 8 | 8 | throw new \Exception("Cannot find vendor directory."); |
| 9 | 9 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | function getTestsDirectory(): string { |
| 20 | - if(!isset($argv[1])) { |
|
| 20 | + if (!isset($argv[1])) { |
|
| 21 | 21 | return dirname(findVendorDirectory()) . "/tests"; |
| 22 | 22 | } |
| 23 | 23 | return $argv[1]; |
@@ -45,10 +45,10 @@ |
||
| 45 | 45 | static::printLine($output . ". $text"); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @param string $results |
|
| 50 | - * @return bool |
|
| 51 | - */ |
|
| 48 | + /** |
|
| 49 | + * @param string $results |
|
| 50 | + * @return bool |
|
| 51 | + */ |
|
| 52 | 52 | static function checkFailed(string $results): bool { |
| 53 | 53 | $testsFailed = substr_count($results, " failed. "); |
| 54 | 54 | return (bool) $testsFailed; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace MyTester; |
| 5 | 5 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | static function testResult(string $text, bool $success = true): void { |
| 40 | 40 | static::incCounter(); |
| 41 | - if($success) { |
|
| 41 | + if ($success) { |
|
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | $output = "Test " . static::$taskCount . " failed"; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @return void |
| 103 | 103 | */ |
| 104 | 104 | static function printLine(string $text): void { |
| 105 | - if(static::$mode == "http") { |
|
| 105 | + if (static::$mode == "http") { |
|
| 106 | 106 | $text .= "<br>"; |
| 107 | 107 | } |
| 108 | 108 | echo "$text\n"; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @return void |
| 158 | 158 | */ |
| 159 | 159 | static function setup(): void { |
| 160 | - if(static::$set) { |
|
| 160 | + if (static::$set) { |
|
| 161 | 161 | static::printLine("Warning: Testing Environment was already set up."); |
| 162 | 162 | return; |
| 163 | 163 | } |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | require_once __DIR__ . "/functions.php"; |
| 5 | 5 | |