diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 1df3eb02..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -build: false -platform: 'x86' -clone_folder: C:\projects\php-workshop -branches: - except: - - gh-pages - -init: - - SET COMPOSER_NO_INTERACTION=1 - -install: - - SET PATH=C:\Program Files\OpenSSL;%PATH% - - cinst php - - cd c:\tools\php - - copy php.ini-production php.ini - - echo date.timezone="UTC" >> php.ini - - echo extension_dir=ext >> php.ini - - echo extension=php_openssl.dll >> php.ini - - echo extension=php_mbstring.dll >> php.ini - - SET PATH=C:\tools\php;%PATH% - - cd C:\projects\php-workshop - - php -r "readfile('http://getcomposer.org/installer');" | php - - php composer.phar install --prefer-source --no-progress - -test_script: - - ps: cd C:\projects\php-workshop - - ps: gl - - vendor\bin\phpunit.bat diff --git a/composer.json b/composer.json index 045f58e7..d4c963ef 100644 --- a/composer.json +++ b/composer.json @@ -52,8 +52,8 @@ }, "scripts" : { "cs" : [ - "phpcs src --standard=PSR2 --encoding=UTF-8", - "phpcs test --standard=PSR2 --encoding=UTF-8" + "phpcs src --standard=PSR12 --encoding=UTF-8", + "phpcs test --standard=PSR12 --encoding=UTF-8" ] } } diff --git a/src/Application.php b/src/Application.php index 41a74c0d..18bff628 100644 --- a/src/Application.php +++ b/src/Application.php @@ -220,7 +220,7 @@ public function run() */ private function getContainer() { - $containerBuilder = new ContainerBuilder; + $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions( array_merge_recursive( require $this->frameworkConfigLocation, diff --git a/src/Check/CheckInterface.php b/src/Check/CheckInterface.php index c1fc2061..fe435d46 100644 --- a/src/Check/CheckInterface.php +++ b/src/Check/CheckInterface.php @@ -10,11 +10,11 @@ interface CheckInterface /** * Return the check's name */ - public function getName() : string; + public function getName(): string; /** * This returns the interface the exercise should implement * when requiring this check. It should be the FQCN of the interface. */ - public function getExerciseInterface() : string; + public function getExerciseInterface(): string; } diff --git a/src/Check/CheckRepository.php b/src/Check/CheckRepository.php index 33e30a55..7565061c 100644 --- a/src/Check/CheckRepository.php +++ b/src/Check/CheckRepository.php @@ -28,7 +28,7 @@ public function __construct(array $checks = []) /** * Add a new check to the repository. */ - public function registerCheck(CheckInterface $check) : void + public function registerCheck(CheckInterface $check): void { $this->checks[get_class($check)] = $check; } @@ -38,7 +38,7 @@ public function registerCheck(CheckInterface $check) : void * * @return array */ - public function getAll() : array + public function getAll(): array { return array_values($this->checks); } @@ -50,7 +50,7 @@ public function getAll() : array * @return CheckInterface The instance. * @throws InvalidArgumentException If an instance of the check does not exist. */ - public function getByClass(string $class) : CheckInterface + public function getByClass(string $class): CheckInterface { if (!isset($this->checks[$class])) { throw new InvalidArgumentException(sprintf('Check: "%s" does not exist', $class)); @@ -62,7 +62,7 @@ public function getByClass(string $class) : CheckInterface /** * Query whether a check instance exists in this repository via its class name. */ - public function has(string $class) : bool + public function has(string $class): bool { try { $this->getByClass($class); diff --git a/src/Check/CodeParseCheck.php b/src/Check/CodeParseCheck.php index 6f557ba6..1330ecf1 100644 --- a/src/Check/CodeParseCheck.php +++ b/src/Check/CodeParseCheck.php @@ -35,7 +35,7 @@ public function __construct(Parser $parser) /** * Return the check's name */ - public function getName() : string + public function getName(): string { return 'Code Parse Check'; } @@ -49,7 +49,7 @@ public function getName() : string * @param Input $input The command line arguments passed to the command. * @return ResultInterface The result of the check. */ - public function check(ExerciseInterface $exercise, Input $input) : ResultInterface + public function check(ExerciseInterface $exercise, Input $input): ResultInterface { $code = file_get_contents($input->getArgument('program')); @@ -66,7 +66,7 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa /** * This check can run on any exercise type. */ - public function canRun(ExerciseType $exerciseType) : bool + public function canRun(ExerciseType $exerciseType): bool { return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true); } @@ -74,7 +74,7 @@ public function canRun(ExerciseType $exerciseType) : bool /** * @return string */ - public function getExerciseInterface() : string + public function getExerciseInterface(): string { return ExerciseInterface::class; } @@ -83,7 +83,7 @@ public function getExerciseInterface() : string * This check should be run before executing the student's solution, as, if it cannot be parsed * it probably cannot be executed. */ - public function getPosition() : string + public function getPosition(): string { return SimpleCheckInterface::CHECK_BEFORE; } diff --git a/src/Check/ComposerCheck.php b/src/Check/ComposerCheck.php index c5cb9f64..1bef0aab 100644 --- a/src/Check/ComposerCheck.php +++ b/src/Check/ComposerCheck.php @@ -21,7 +21,7 @@ class ComposerCheck implements SimpleCheckInterface /** * Return the check's name */ - public function getName() : string + public function getName(): string { return 'Composer Dependency Check'; } @@ -35,10 +35,10 @@ public function getName() : string * @param Input $input The command line arguments passed to the command. * @return ResultInterface The result of the check. */ - public function check(ExerciseInterface $exercise, Input $input) : ResultInterface + public function check(ExerciseInterface $exercise, Input $input): ResultInterface { if (!$exercise instanceof ComposerExerciseCheck) { - throw new \InvalidArgumentException; + throw new \InvalidArgumentException(); } if (!file_exists(sprintf('%s/composer.json', dirname($input->getArgument('program'))))) { @@ -74,12 +74,12 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa /** * This check can run on any exercise type. */ - public function canRun(ExerciseType $exerciseType) : bool + public function canRun(ExerciseType $exerciseType): bool { return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true); } - public function getExerciseInterface() : string + public function getExerciseInterface(): string { return ComposerExerciseCheck::class; } @@ -87,7 +87,7 @@ public function getExerciseInterface() : string /** * This check can run before because if it fails, there is no point executing the solution. */ - public function getPosition() : string + public function getPosition(): string { return SimpleCheckInterface::CHECK_BEFORE; } diff --git a/src/Check/DatabaseCheck.php b/src/Check/DatabaseCheck.php index b9084afc..2f1f65d1 100644 --- a/src/Check/DatabaseCheck.php +++ b/src/Check/DatabaseCheck.php @@ -61,12 +61,12 @@ public function __construct() /** * Return the check's name */ - public function getName() : string + public function getName(): string { return 'Database Verification Check'; } - public function getExerciseInterface() : string + public function getExerciseInterface(): string { return DatabaseExerciseCheck::class; } @@ -75,7 +75,7 @@ public function getExerciseInterface() : string * Here we attach to various events to seed, verify and inject the DSN's * to the student & reference solution programs's CLI arguments. */ - public function attach(EventDispatcher $eventDispatcher) : void + public function attach(EventDispatcher $eventDispatcher): void { if (file_exists($this->databaseDirectory)) { throw new \RuntimeException( diff --git a/src/Check/FileExistsCheck.php b/src/Check/FileExistsCheck.php index 35b9fc0d..d569eaad 100644 --- a/src/Check/FileExistsCheck.php +++ b/src/Check/FileExistsCheck.php @@ -17,7 +17,7 @@ class FileExistsCheck implements SimpleCheckInterface /** * Return the check's name. */ - public function getName() : string + public function getName(): string { return 'File Exists Check'; } @@ -29,7 +29,7 @@ public function getName() : string * @param Input $input The command line arguments passed to the command. * @return ResultInterface The result of the check. */ - public function check(ExerciseInterface $exercise, Input $input) : ResultInterface + public function check(ExerciseInterface $exercise, Input $input): ResultInterface { if (file_exists($input->getArgument('program'))) { return Success::fromCheck($this); @@ -41,12 +41,12 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa /** * This check can run on any exercise type. */ - public function canRun(ExerciseType $exerciseType) : bool + public function canRun(ExerciseType $exerciseType): bool { return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true); } - public function getExerciseInterface() : string + public function getExerciseInterface(): string { return ExerciseInterface::class; } @@ -54,7 +54,7 @@ public function getExerciseInterface() : string /** * This check must run before executing the solution becuase it may not exist. */ - public function getPosition() : string + public function getPosition(): string { return SimpleCheckInterface::CHECK_BEFORE; } diff --git a/src/Check/FunctionRequirementsCheck.php b/src/Check/FunctionRequirementsCheck.php index 112e6ff0..ba42f3ea 100644 --- a/src/Check/FunctionRequirementsCheck.php +++ b/src/Check/FunctionRequirementsCheck.php @@ -39,7 +39,7 @@ public function __construct(Parser $parser) /** * Return the check's name. */ - public function getName() : string + public function getName(): string { return 'Function Requirements Check'; } @@ -53,10 +53,10 @@ public function getName() : string * @param Input $input The command line arguments passed to the command. * @return ResultInterface The result of the check. */ - public function check(ExerciseInterface $exercise, Input $input) : ResultInterface + public function check(ExerciseInterface $exercise, Input $input): ResultInterface { if (!$exercise instanceof FunctionRequirementsExerciseCheck) { - throw new \InvalidArgumentException; + throw new \InvalidArgumentException(); } $requiredFunctions = $exercise->getRequiredFunctions(); @@ -71,7 +71,7 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa } $visitor = new FunctionVisitor($requiredFunctions, $bannedFunctions); - $traverser = new NodeTraverser; + $traverser = new NodeTraverser(); $traverser->addVisitor($visitor); $traverser->traverse($ast); @@ -98,12 +98,12 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa /** * This check can run on any exercise type. */ - public function canRun(ExerciseType $exerciseType) : bool + public function canRun(ExerciseType $exerciseType): bool { return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true); } - public function getExerciseInterface() : string + public function getExerciseInterface(): string { return FunctionRequirementsExerciseCheck::class; } @@ -113,7 +113,7 @@ public function getExerciseInterface() : string * output, but do it in a way that was not correct for the task. This way the student can see the program works * but missed some requirements. */ - public function getPosition() : string + public function getPosition(): string { return SimpleCheckInterface::CHECK_AFTER; } diff --git a/src/Check/ListenableCheckInterface.php b/src/Check/ListenableCheckInterface.php index 53835d21..a7e705d0 100644 --- a/src/Check/ListenableCheckInterface.php +++ b/src/Check/ListenableCheckInterface.php @@ -13,5 +13,5 @@ interface ListenableCheckInterface extends CheckInterface * Attach to events throughout the running/verifying process. Inject verifiers * and listeners. */ - public function attach(EventDispatcher $eventDispatcher) : void; + public function attach(EventDispatcher $eventDispatcher): void; } diff --git a/src/Check/PhpLintCheck.php b/src/Check/PhpLintCheck.php index 1a6788ca..2ddf0613 100644 --- a/src/Check/PhpLintCheck.php +++ b/src/Check/PhpLintCheck.php @@ -20,7 +20,7 @@ class PhpLintCheck implements SimpleCheckInterface /** * Return the check's name */ - public function getName() : string + public function getName(): string { return 'PHP Code Check'; } @@ -32,7 +32,7 @@ public function getName() : string * @param Input $input The command line arguments passed to the command. * @return ResultInterface The result of the check. */ - public function check(ExerciseInterface $exercise, Input $input) : ResultInterface + public function check(ExerciseInterface $exercise, Input $input): ResultInterface { $process = new Process([PHP_BINARY, '-l', $input->getArgument('program')]); $process->run(); @@ -47,12 +47,12 @@ public function check(ExerciseInterface $exercise, Input $input) : ResultInterfa /** * This check can run on any exercise type. */ - public function canRun(ExerciseType $exerciseType) : bool + public function canRun(ExerciseType $exerciseType): bool { return in_array($exerciseType->getValue(), [ExerciseType::CGI, ExerciseType::CLI], true); } - public function getExerciseInterface() : string + public function getExerciseInterface(): string { return ExerciseInterface::class; } @@ -61,7 +61,7 @@ public function getExerciseInterface() : string * This check should be run before executing the student's solution, as, if it cannot be linted * it probably cannot be executed. */ - public function getPosition() : string + public function getPosition(): string { return SimpleCheckInterface::CHECK_BEFORE; } diff --git a/src/Check/SimpleCheckInterface.php b/src/Check/SimpleCheckInterface.php index 21b99be5..44e62332 100644 --- a/src/Check/SimpleCheckInterface.php +++ b/src/Check/SimpleCheckInterface.php @@ -30,7 +30,7 @@ interface SimpleCheckInterface extends CheckInterface /** * Can this check run this exercise? */ - public function canRun(ExerciseType $exerciseType) : bool; + public function canRun(ExerciseType $exerciseType): bool; /** * The check is ran against an exercise and a filename which @@ -45,12 +45,12 @@ public function canRun(ExerciseType $exerciseType) : bool; * @param Input $input The command line arguments passed to the command. * @return ResultInterface The result of the check. */ - public function check(ExerciseInterface $exercise, Input $input) : ResultInterface; + public function check(ExerciseInterface $exercise, Input $input): ResultInterface; /** * Either `static::CHECK_BEFORE` | `static::CHECK_AFTER`. * * @return string */ - public function getPosition() : string; + public function getPosition(): string; } diff --git a/src/CodeInsertion.php b/src/CodeInsertion.php index f916ca7e..0b4c3f48 100644 --- a/src/CodeInsertion.php +++ b/src/CodeInsertion.php @@ -14,13 +14,13 @@ class CodeInsertion * Denotes that the block of code this insertion * represents, should be inserted at the top of the solution. */ - const TYPE_BEFORE = 'before'; + public const TYPE_BEFORE = 'before'; /** * Denotes that the block of code this insertion * represents, should be inserted at the bottom of the solution. */ - const TYPE_AFTER = 'after'; + public const TYPE_AFTER = 'after'; /** * @var array diff --git a/src/CommandRouter.php b/src/CommandRouter.php index f0bcd37b..e5cc1e7e 100644 --- a/src/CommandRouter.php +++ b/src/CommandRouter.php @@ -221,7 +221,7 @@ private function resolveCallable(CommandDefinition $command, Input $input) * @param Input $input * @return int */ - private function callCommand(CommandDefinition $command, callable $callable, Input $input) + private function callCommand(CommandDefinition $command, callable $callable, Input $input) { $this->eventDispatcher->dispatch(new Event\Event('route.pre.invoke')); $this->eventDispatcher->dispatch(new Event\Event(sprintf('route.pre.invoke.%s', $command->getName()))); diff --git a/src/Exercise/ExerciseType.php b/src/Exercise/ExerciseType.php index 73975640..88640292 100644 --- a/src/Exercise/ExerciseType.php +++ b/src/Exercise/ExerciseType.php @@ -15,9 +15,9 @@ */ class ExerciseType extends Enum { - const CLI = 'CLI'; - const CGI = 'CGI'; - const CUSTOM = 'CUSTOM'; + public const CLI = 'CLI'; + public const CGI = 'CGI'; + public const CUSTOM = 'CUSTOM'; /** diff --git a/src/Factory/EventDispatcherFactory.php b/src/Factory/EventDispatcherFactory.php index abbefe0a..2bdd9683 100644 --- a/src/Factory/EventDispatcherFactory.php +++ b/src/Factory/EventDispatcherFactory.php @@ -70,7 +70,7 @@ private function mergeListenerGroups(array $listeners) array_merge($carry->get($event, []), $listeners) ); }, $carry); - }, new Collection) + }, new Collection()) ->getArrayCopy(); } diff --git a/src/Factory/MarkdownCliRendererFactory.php b/src/Factory/MarkdownCliRendererFactory.php index 9c746726..97a90c0b 100644 --- a/src/Factory/MarkdownCliRendererFactory.php +++ b/src/Factory/MarkdownCliRendererFactory.php @@ -50,25 +50,25 @@ public function __invoke(ContainerInterface $c) $terminal = $c->get(Terminal::class); $codeRender = new FencedCodeRenderer(); - $codeRender->addSyntaxHighlighter('php', new PhpHighlighter(new KeyLighter)); + $codeRender->addSyntaxHighlighter('php', new PhpHighlighter(new KeyLighter())); $blockRenderers = [ - Document::class => new DocumentRenderer, - Heading::class => new HeaderRenderer, + Document::class => new DocumentRenderer(), + Heading::class => new HeaderRenderer(), ThematicBreak::class => new HorizontalRuleRenderer($terminal->getWidth()), - Paragraph::class => new ParagraphRenderer, + Paragraph::class => new ParagraphRenderer(), FencedCode::class => $codeRender, - ListBlock::class => new ListBlockRenderer, - ListItem::class => new ListItemRenderer, + ListBlock::class => new ListBlockRenderer(), + ListItem::class => new ListItemRenderer(), ]; $inlineBlockRenderers = [ - Text::class => new TextRenderer, - Code::class => new CodeRenderer, - Emphasis::class => new EmphasisRenderer, - Strong::class => new StrongRenderer, - Newline::class => new NewlineRenderer, - Link::class => new LinkRenderer, + Text::class => new TextRenderer(), + Code::class => new CodeRenderer(), + Emphasis::class => new EmphasisRenderer(), + Strong::class => new StrongRenderer(), + Newline::class => new NewlineRenderer(), + Link::class => new LinkRenderer(), ]; return new CliRenderer( diff --git a/src/Factory/ResultRendererFactory.php b/src/Factory/ResultRendererFactory.php index cc768a9e..99504808 100644 --- a/src/Factory/ResultRendererFactory.php +++ b/src/Factory/ResultRendererFactory.php @@ -26,11 +26,11 @@ class ResultRendererFactory public function registerRenderer($resultClass, $rendererClass, callable $factory = null) { if (!$this->isImplementationNameOfClass($resultClass, ResultInterface::class)) { - throw new InvalidArgumentException; + throw new InvalidArgumentException(); } if (!$this->isImplementationNameOfClass($rendererClass, ResultRendererInterface::class)) { - throw new InvalidArgumentException; + throw new InvalidArgumentException(); } $this->mappings[$resultClass] = $rendererClass; diff --git a/src/MenuItem/ResetProgress.php b/src/MenuItem/ResetProgress.php index 0de14847..8731f527 100644 --- a/src/MenuItem/ResetProgress.php +++ b/src/MenuItem/ResetProgress.php @@ -27,7 +27,7 @@ public function __construct(UserStateSerializer $userStateSerializer) */ public function __invoke(CliMenu $menu) { - $this->userStateSerializer->serialize(new UserState); + $this->userStateSerializer->serialize(new UserState()); $items = $menu ->getParent() diff --git a/src/ResultRenderer/ResultsRenderer.php b/src/ResultRenderer/ResultsRenderer.php index 9c847dda..cd78c990 100644 --- a/src/ResultRenderer/ResultsRenderer.php +++ b/src/ResultRenderer/ResultsRenderer.php @@ -95,7 +95,8 @@ public function render( $successes = []; $failures = []; foreach ($results as $result) { - if ($result instanceof SuccessInterface + if ( + $result instanceof SuccessInterface || ($result instanceof ResultGroupInterface && $result->isSuccessful()) ) { $successes[] = sprintf(' ✔ Check: %s', $result->getCheckName()); @@ -188,7 +189,7 @@ private function renderSuccessInformation( $code = $this->keyLighter->highlight( $file->getContents(), $this->keyLighter->languageByExt('.' . $file->getExtension()), - new CliFormatter + new CliFormatter() ); //make sure there is a new line at the end diff --git a/src/UserStateSerializer.php b/src/UserStateSerializer.php index 27d25918..afcd5524 100644 --- a/src/UserStateSerializer.php +++ b/src/UserStateSerializer.php @@ -20,12 +20,12 @@ class UserStateSerializer /** * @var string */ - const LEGACY_SAVE_FILE = '.phpschool.json'; + private const LEGACY_SAVE_FILE = '.phpschool.json'; /** * @var string */ - const SAVE_FILE = '.phpschool-save.json'; + private const SAVE_FILE = '.phpschool-save.json'; /** * @var ExerciseRepository diff --git a/src/WorkshopType.php b/src/WorkshopType.php index 7157f1de..52f26d66 100644 --- a/src/WorkshopType.php +++ b/src/WorkshopType.php @@ -11,8 +11,8 @@ */ class WorkshopType extends Enum { - const STANDARD = 1; - const TUTORIAL = 2; + public const STANDARD = 1; + public const TUTORIAL = 2; /** * @return bool diff --git a/test/ApplicationTest.php b/test/ApplicationTest.php index 89ba67f9..aab962e4 100644 --- a/test/ApplicationTest.php +++ b/test/ApplicationTest.php @@ -1,4 +1,6 @@ -name = $name; } - public function getName() : string + public function getName(): string { return $this->name; } diff --git a/test/Asset/CgiExerciseImpl.php b/test/Asset/CgiExerciseImpl.php index 0b8532d5..58787c9b 100644 --- a/test/Asset/CgiExerciseImpl.php +++ b/test/Asset/CgiExerciseImpl.php @@ -25,27 +25,27 @@ public function __construct(string $name = 'my-exercise') $this->name = $name; } - public function getName() : string + public function getName(): string { return $this->name; } - public function getDescription() : string + public function getDescription(): string { return $this->name; } - public function getSolution() : string + public function getSolution(): string { // TODO: Implement getSolution() method. } - public function getProblem() : string + public function getProblem(): string { // TODO: Implement getProblem() method. } - public function tearDown() : void + public function tearDown(): void { // TODO: Implement tearDown() method. } @@ -56,17 +56,17 @@ public function tearDown() : void * * @return RequestInterface[] An array of PSR-7 requests. */ - public function getRequests() : array + public function getRequests(): array { return []; // TODO: Implement getRequests() method. } - public function getType() : ExerciseType + public function getType(): ExerciseType { return ExerciseType::CGI(); } - public function configure(ExerciseDispatcher $dispatcher) : void + public function configure(ExerciseDispatcher $dispatcher): void { } } diff --git a/test/Asset/CliExerciseImpl.php b/test/Asset/CliExerciseImpl.php index 681ea1ff..0b8bf64d 100644 --- a/test/Asset/CliExerciseImpl.php +++ b/test/Asset/CliExerciseImpl.php @@ -24,42 +24,42 @@ public function __construct(string $name = 'my-exercise') $this->name = $name; } - public function getName() : string + public function getName(): string { return $this->name; } - public function getDescription() : string + public function getDescription(): string { return $this->name; } - public function getSolution() : string + public function getSolution(): string { // TODO: Implement getSolution() method. } - public function getProblem() : string + public function getProblem(): string { // TODO: Implement getProblem() method. } - public function tearDown() : void + public function tearDown(): void { // TODO: Implement tearDown() method. } - public function getArgs() : array + public function getArgs(): array { return []; // TODO: Implement getArgs() method. } - public function getType() : ExerciseType + public function getType(): ExerciseType { return ExerciseType::CLI(); } - public function configure(ExerciseDispatcher $dispatcher) : void + public function configure(ExerciseDispatcher $dispatcher): void { } } diff --git a/test/Asset/CliExerciseMissingInterface.php b/test/Asset/CliExerciseMissingInterface.php index 95ce53a9..592061f5 100644 --- a/test/Asset/CliExerciseMissingInterface.php +++ b/test/Asset/CliExerciseMissingInterface.php @@ -15,7 +15,7 @@ class CliExerciseMissingInterface extends AbstractExercise implements ExerciseIn /** * Get the name of the exercise, like `Hello World!`. */ - public function getName() : string + public function getName(): string { return 'CLI exercise missing interface'; } @@ -23,7 +23,7 @@ public function getName() : string /** * A short description of the exercise. */ - public function getDescription() : string + public function getDescription(): string { return 'CLI exercise missing interface'; } @@ -31,7 +31,7 @@ public function getDescription() : string /** * Return the type of exercise. This is an ENUM. See `PhpSchool\PhpWorkshop\Exercise\ExerciseType`. */ - public function getType() : ExerciseType + public function getType(): ExerciseType { return ExerciseType::CLI(); } diff --git a/test/Asset/ComposerExercise.php b/test/Asset/ComposerExercise.php index 0584c154..0d1c01bb 100644 --- a/test/Asset/ComposerExercise.php +++ b/test/Asset/ComposerExercise.php @@ -15,37 +15,37 @@ */ class ComposerExercise implements ExerciseInterface, ComposerExerciseCheck { - public function getName() : string + public function getName(): string { return 'composer-exercise'; } - public function getDescription() : string + public function getDescription(): string { // TODO: Implement getDescription() method. } - public function getSolution() : string + public function getSolution(): string { // TODO: Implement getSolution() method. } - public function getProblem() : string + public function getProblem(): string { // TODO: Implement getProblem() method. } - public function tearDown() : void + public function tearDown(): void { // TODO: Implement tearDown() method. } - public function getArgs() : array + public function getArgs(): array { return []; // TODO: Implement getArgs() method. } - public function getRequiredPackages() : array + public function getRequiredPackages(): array { return [ 'klein/klein', @@ -53,12 +53,12 @@ public function getRequiredPackages() : array ]; } - public function getType() : ExerciseType + public function getType(): ExerciseType { return ExerciseType::CLI(); } - public function configure(ExerciseDispatcher $dispatcher) : void + public function configure(ExerciseDispatcher $dispatcher): void { $dispatcher->requireCheck(ComposerCheck::class); } diff --git a/test/Asset/CustomVerifyingExerciseImpl.php b/test/Asset/CustomVerifyingExerciseImpl.php index 7d1b1a3f..f8cf4c64 100644 --- a/test/Asset/CustomVerifyingExerciseImpl.php +++ b/test/Asset/CustomVerifyingExerciseImpl.php @@ -18,7 +18,7 @@ class CustomVerifyingExerciseImpl extends AbstractExercise implements ExerciseIn /** * Get the name of the exercise, like `Hello World!`. */ - public function getName() : string + public function getName(): string { return 'Custom Verifying exercise'; } @@ -26,7 +26,7 @@ public function getName() : string /** * A short description of the exercise. */ - public function getDescription() : string + public function getDescription(): string { return 'Custom Verifying exercise'; } @@ -34,12 +34,12 @@ public function getDescription() : string /** * Return the type of exercise. This is an ENUM. See `PhpSchool\PhpWorkshop\Exercise\ExerciseType`. */ - public function getType() : ExerciseType + public function getType(): ExerciseType { return ExerciseType::CUSTOM(); } - public function verify() : ResultInterface + public function verify(): ResultInterface { return new Success('success'); } diff --git a/test/Asset/FunctionRequirementsExercise.php b/test/Asset/FunctionRequirementsExercise.php index 91c38bdd..7deb0189 100644 --- a/test/Asset/FunctionRequirementsExercise.php +++ b/test/Asset/FunctionRequirementsExercise.php @@ -15,37 +15,37 @@ */ class FunctionRequirementsExercise implements ExerciseInterface, FunctionRequirementsExerciseCheck { - public function getName() : string + public function getName(): string { // TODO: Implement getName() method. } - public function getDescription() : string + public function getDescription(): string { // TODO: Implement getDescription() method. } - public function getSolution() : string + public function getSolution(): string { // TODO: Implement getSolution() method. } - public function getProblem() : string + public function getProblem(): string { // TODO: Implement getProblem() method. } - public function tearDown() : void + public function tearDown(): void { // TODO: Implement tearDown() method. } - public function getArgs() : array + public function getArgs(): array { return []; // TODO: Implement getArgs() method. } - public function getRequiredPackages() : array + public function getRequiredPackages(): array { return [ 'klein/klein', @@ -53,12 +53,12 @@ public function getRequiredPackages() : array ]; } - public function getType() : ExerciseType + public function getType(): ExerciseType { return ExerciseType::CLI(); } - public function configure(ExerciseDispatcher $dispatcher) : void + public function configure(ExerciseDispatcher $dispatcher): void { $dispatcher->requireCheck(ComposerCheck::class); } @@ -66,7 +66,7 @@ public function configure(ExerciseDispatcher $dispatcher) : void /** * @return string[] */ - public function getRequiredFunctions() : array + public function getRequiredFunctions(): array { return []; } @@ -74,7 +74,7 @@ public function getRequiredFunctions() : array /** * @return string[] */ - public function getBannedFunctions() : array + public function getBannedFunctions(): array { return ['file']; } diff --git a/test/Asset/PatchableExercise.php b/test/Asset/PatchableExercise.php index 27383acf..d7bb9792 100644 --- a/test/Asset/PatchableExercise.php +++ b/test/Asset/PatchableExercise.php @@ -15,42 +15,42 @@ */ class PatchableExercise implements ExerciseInterface, SubmissionPatchable { - public function getName() : string + public function getName(): string { // TODO: Implement getName() method. } - public function getDescription() : string + public function getDescription(): string { // TODO: Implement getDescription() method. } - public function getSolution() : string + public function getSolution(): string { // TODO: Implement getSolution() method. } - public function getProblem() : string + public function getProblem(): string { // TODO: Implement getProblem() method. } - public function tearDown() : void + public function tearDown(): void { // TODO: Implement tearDown() method. } - public function getPatch() : Patch + public function getPatch(): Patch { // TODO: Implement getPatch() method. } - public function getType() : ExerciseType + public function getType(): ExerciseType { // TODO: Implement getType() method. } - public function configure(ExerciseDispatcher $dispatcher) : void + public function configure(ExerciseDispatcher $dispatcher): void { // TODO: Implement configure() method. } diff --git a/test/Asset/ResultResultAggregator.php b/test/Asset/ResultResultAggregator.php index a2a77ad0..f96aa917 100644 --- a/test/Asset/ResultResultAggregator.php +++ b/test/Asset/ResultResultAggregator.php @@ -12,7 +12,7 @@ */ class ResultResultAggregator extends ResultAggregator implements ResultInterface { - public function getCheckName() : string + public function getCheckName(): string { return self::class; } diff --git a/test/Asset/TemporaryDirectoryTraitImpl.php b/test/Asset/TemporaryDirectoryTraitImpl.php index 7867fa2d..a9b5ec46 100644 --- a/test/Asset/TemporaryDirectoryTraitImpl.php +++ b/test/Asset/TemporaryDirectoryTraitImpl.php @@ -11,6 +11,7 @@ */ class TemporaryDirectoryTraitImpl { - use TemporaryDirectoryTrait { getTemporaryPath as public; + use TemporaryDirectoryTrait { + getTemporaryPath as public; } } diff --git a/test/Check/CheckRepositoryTest.php b/test/Check/CheckRepositoryTest.php index 8eed6d15..385ff86a 100644 --- a/test/Check/CheckRepositoryTest.php +++ b/test/Check/CheckRepositoryTest.php @@ -14,16 +14,16 @@ */ class CheckRepositoryTest extends TestCase { - public function testRegisterViaConstructor() : void + public function testRegisterViaConstructor(): void { $check = $this->createMock(CheckInterface::class); $repository = new CheckRepository([$check]); $this->assertEquals([$check], $repository->getAll()); } - public function testRegisterCheck() : void + public function testRegisterCheck(): void { - $repository = new CheckRepository; + $repository = new CheckRepository(); $this->assertEquals([], $repository->getAll()); $check = $this->createMock(CheckInterface::class); @@ -31,9 +31,9 @@ public function testRegisterCheck() : void $this->assertEquals([$check], $repository->getAll()); } - public function testHas() : void + public function testHas(): void { - $repository = new CheckRepository; + $repository = new CheckRepository(); $repository->registerCheck($this->createMock(CheckInterface::class)); $check = $this->createMock(CheckInterface::class); @@ -43,9 +43,9 @@ public function testHas() : void $this->assertFalse($repository->has('SomeClassWhichDoesNotExist')); } - public function testGetByClassThrowsExceptionIfNotExist() : void + public function testGetByClassThrowsExceptionIfNotExist(): void { - $repository = new CheckRepository; + $repository = new CheckRepository(); $repository->registerCheck($this->createMock(CheckInterface::class)); $this->expectException(InvalidArgumentException::class); @@ -54,9 +54,9 @@ public function testGetByClassThrowsExceptionIfNotExist() : void $repository->getByClass('SomeClassWhichDoesNotExist'); } - public function testGetByClass() : void + public function testGetByClass(): void { - $repository = new CheckRepository; + $repository = new CheckRepository(); $repository->registerCheck($this->createMock(CheckInterface::class)); $check = $this->createMock(CheckInterface::class); diff --git a/test/Check/CodeParseCheckTest.php b/test/Check/CodeParseCheckTest.php index 329764fb..4c7e79e8 100644 --- a/test/Check/CodeParseCheckTest.php +++ b/test/Check/CodeParseCheckTest.php @@ -24,9 +24,9 @@ class CodeParseCheckTest extends TestCase */ private $file; - public function setUp() : void + public function setUp(): void { - $this->check = new CodeParseCheck((new ParserFactory)->create(ParserFactory::PREFER_PHP7)); + $this->check = new CodeParseCheck((new ParserFactory())->create(ParserFactory::PREFER_PHP7)); $this->assertEquals('Code Parse Check', $this->check->getName()); $this->assertEquals(ExerciseInterface::class, $this->check->getExerciseInterface()); $this->assertEquals(SimpleCheckInterface::CHECK_BEFORE, $this->check->getPosition()); @@ -39,7 +39,7 @@ public function setUp() : void touch($this->file); } - public function testUnParseableCodeReturnsFailure() : void + public function testUnParseableCodeReturnsFailure(): void { file_put_contents($this->file, 'file, 'check = new ComposerCheck; - $this->exercise = new ComposerExercise; + $this->check = new ComposerCheck(); + $this->exercise = new ComposerExercise(); $this->assertEquals('Composer Dependency Check', $this->check->getName()); $this->assertEquals(ComposerExerciseCheck::class, $this->check->getExerciseInterface()); $this->assertEquals(SimpleCheckInterface::CHECK_BEFORE, $this->check->getPosition()); @@ -43,7 +43,7 @@ public function setUp() : void $this->assertTrue($this->check->canRun(ExerciseType::CLI())); } - public function testExceptionIsThrownIfNotValidExercise() : void + public function testExceptionIsThrownIfNotValidExercise(): void { $exercise = $this->createMock(ExerciseInterface::class); $this->expectException(InvalidArgumentException::class); @@ -51,7 +51,7 @@ public function testExceptionIsThrownIfNotValidExercise() : void $this->check->check($exercise, new Input('app')); } - public function testCheckReturnsFailureIfNoComposerFile() : void + public function testCheckReturnsFailureIfNoComposerFile(): void { $result = $this->check->check( $this->exercise, @@ -63,7 +63,7 @@ public function testCheckReturnsFailureIfNoComposerFile() : void $this->assertSame('No composer.json file found', $result->getReason()); } - public function testCheckReturnsFailureIfNoComposerLockFile() : void + public function testCheckReturnsFailureIfNoComposerLockFile(): void { $result = $this->check->check( $this->exercise, @@ -75,7 +75,7 @@ public function testCheckReturnsFailureIfNoComposerLockFile() : void $this->assertSame('No composer.lock file found', $result->getReason()); } - public function testCheckReturnsFailureIfNoVendorFolder() : void + public function testCheckReturnsFailureIfNoVendorFolder(): void { $result = $this->check->check( $this->exercise, @@ -93,7 +93,7 @@ public function testCheckReturnsFailureIfNoVendorFolder() : void * @param string $dependency * @param string $solutionFile */ - public function testCheckReturnsFailureIfDependencyNotRequired($dependency, $solutionFile) : void + public function testCheckReturnsFailureIfDependencyNotRequired($dependency, $solutionFile): void { $exercise = $this->createMock(ComposerExercise::class); $exercise->expects($this->once()) @@ -113,7 +113,7 @@ public function testCheckReturnsFailureIfDependencyNotRequired($dependency, $sol /** * @return array */ - public function dependencyProvider() : array + public function dependencyProvider(): array { return [ ['klein/klein', __DIR__ . '/../res/composer/no-klein/solution.php'], @@ -121,7 +121,7 @@ public function dependencyProvider() : array ]; } - public function testCheckReturnsSuccessIfCorrectLockFile() : void + public function testCheckReturnsSuccessIfCorrectLockFile(): void { $result = $this->check->check( $this->exercise, diff --git a/test/Check/DatabaseCheckTest.php b/test/Check/DatabaseCheckTest.php index d1768f9e..7b63becb 100644 --- a/test/Check/DatabaseCheckTest.php +++ b/test/Check/DatabaseCheckTest.php @@ -50,15 +50,15 @@ class DatabaseCheckTest extends TestCase */ private $dbDir; - public function setUp() : void + public function setUp(): void { - $containerBuilder = new ContainerBuilder; + $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions(__DIR__ . '/../../app/config.php'); $container = $containerBuilder->build(); $this->checkRepository = $container->get(CheckRepository::class); - $this->check = new DatabaseCheck; + $this->check = new DatabaseCheck(); $this->exercise = $this->createMock(DatabaseExerciseInterface::class); $this->exercise->method('getType')->willReturn(ExerciseType::CLI()); $this->dbDir = sprintf( @@ -70,7 +70,7 @@ public function setUp() : void $this->assertEquals(DatabaseExerciseCheck::class, $this->check->getExerciseInterface()); } - private function getRunnerManager(ExerciseInterface $exercise, EventDispatcher $eventDispatcher) : MockObject + private function getRunnerManager(ExerciseInterface $exercise, EventDispatcher $eventDispatcher): MockObject { $runner = $this->getMockBuilder(CliRunner::class) ->setConstructorArgs([$exercise, $eventDispatcher]) @@ -90,9 +90,9 @@ private function getRunnerManager(ExerciseInterface $exercise, EventDispatcher $ return $runnerManager; } - public function testIfDatabaseFolderExistsExceptionIsThrown() : void + public function testIfDatabaseFolderExistsExceptionIsThrown(): void { - $eventDispatcher = new EventDispatcher(new ResultAggregator); + $eventDispatcher = new EventDispatcher(new ResultAggregator()); @mkdir($this->dbDir); try { $this->check->attach($eventDispatcher); @@ -107,9 +107,9 @@ public function testIfDatabaseFolderExistsExceptionIsThrown() : void * If an exception is thrown from PDO, check that the check can be run straight away * Previously files were not cleaned up that caused exceptions. */ - public function testIfPDOThrowsExceptionItCleansUp() : void + public function testIfPDOThrowsExceptionItCleansUp(): void { - $eventDispatcher = new EventDispatcher(new ResultAggregator); + $eventDispatcher = new EventDispatcher(new ResultAggregator()); $refProp = new ReflectionProperty(DatabaseCheck::class, 'userDsn'); $refProp->setAccessible(true); @@ -122,7 +122,7 @@ public function testIfPDOThrowsExceptionItCleansUp() : void } //try to run the check as usual - $this->check = new DatabaseCheck; + $this->check = new DatabaseCheck(); $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/database/solution.php')); $this->exercise ->expects($this->once()) @@ -149,7 +149,7 @@ public function testIfPDOThrowsExceptionItCleansUp() : void $this->checkRepository->registerCheck($this->check); - $results = new ResultAggregator; + $results = new ResultAggregator(); $eventDispatcher = new EventDispatcher($results); $dispatcher = new ExerciseDispatcher( $this->getRunnerManager($this->exercise, $eventDispatcher), @@ -162,7 +162,7 @@ public function testIfPDOThrowsExceptionItCleansUp() : void $this->assertTrue($results->isSuccessful()); } - public function testSuccessIsReturnedIfDatabaseVerificationPassed() : void + public function testSuccessIsReturnedIfDatabaseVerificationPassed(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/database/solution.php')); $this->exercise @@ -190,7 +190,7 @@ public function testSuccessIsReturnedIfDatabaseVerificationPassed() : void $this->checkRepository->registerCheck($this->check); - $results = new ResultAggregator; + $results = new ResultAggregator(); $eventDispatcher = new EventDispatcher($results); $dispatcher = new ExerciseDispatcher( $this->getRunnerManager($this->exercise, $eventDispatcher), @@ -205,7 +205,7 @@ public function testSuccessIsReturnedIfDatabaseVerificationPassed() : void $this->assertTrue($results->isSuccessful()); } - public function testRunExercise() : void + public function testRunExercise(): void { $this->exercise ->expects($this->once()) @@ -221,7 +221,7 @@ public function testRunExercise() : void $this->checkRepository->registerCheck($this->check); - $results = new ResultAggregator; + $results = new ResultAggregator(); $eventDispatcher = new EventDispatcher($results); $dispatcher = new ExerciseDispatcher( $this->getRunnerManager($this->exercise, $eventDispatcher), @@ -237,7 +237,7 @@ public function testRunExercise() : void ); } - public function testFailureIsReturnedIfDatabaseVerificationFails() : void + public function testFailureIsReturnedIfDatabaseVerificationFails(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/database/solution.php')); @@ -267,7 +267,7 @@ public function testFailureIsReturnedIfDatabaseVerificationFails() : void $this->checkRepository->registerCheck($this->check); - $results = new ResultAggregator; + $results = new ResultAggregator(); $eventDispatcher = new EventDispatcher($results); $dispatcher = new ExerciseDispatcher( $this->getRunnerManager($this->exercise, $eventDispatcher), @@ -283,7 +283,7 @@ public function testFailureIsReturnedIfDatabaseVerificationFails() : void $this->assertSame('Database verification failed', $results[1]->getReason()); } - public function testAlteringDatabaseInSolutionDoesNotEffectDatabaseInUserSolution() : void + public function testAlteringDatabaseInSolutionDoesNotEffectDatabaseInUserSolution(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/database/solution-alter-db.php')); @@ -334,7 +334,7 @@ public function testAlteringDatabaseInSolutionDoesNotEffectDatabaseInUserSolutio $this->checkRepository->registerCheck($this->check); - $results = new ResultAggregator; + $results = new ResultAggregator(); $eventDispatcher = new EventDispatcher($results); $dispatcher = new ExerciseDispatcher( $this->getRunnerManager($this->exercise, $eventDispatcher), diff --git a/test/Check/FileExistsCheckTest.php b/test/Check/FileExistsCheckTest.php index 865158f8..0f19e41f 100644 --- a/test/Check/FileExistsCheckTest.php +++ b/test/Check/FileExistsCheckTest.php @@ -33,11 +33,11 @@ class FileExistsCheckTest extends TestCase */ private $exercise; - public function setUp() : void + public function setUp(): void { $this->testDir = sprintf('%s/%s', sys_get_temp_dir(), $this->getName()); mkdir($this->testDir, 0777, true); - $this->check = new FileExistsCheck; + $this->check = new FileExistsCheck(); $this->exercise = $this->createMock(ExerciseInterface::class); $this->assertEquals('File Exists Check', $this->check->getName()); $this->assertEquals(ExerciseInterface::class, $this->check->getExerciseInterface()); @@ -47,7 +47,7 @@ public function setUp() : void $this->assertTrue($this->check->canRun(ExerciseType::CLI())); } - public function testSuccess() : void + public function testSuccess(): void { $file = sprintf('%s/test.txt', $this->testDir); touch($file); @@ -59,7 +59,7 @@ public function testSuccess() : void unlink($file); } - public function testFailure() : void + public function testFailure(): void { $file = sprintf('%s/test.txt', $this->testDir); $failure = $this->check->check($this->exercise, new Input('app', ['program' => $file])); @@ -67,7 +67,7 @@ public function testFailure() : void $this->assertEquals(sprintf('File: "%s" does not exist', $file), $failure->getReason()); } - public function tearDown() : void + public function tearDown(): void { rmdir($this->testDir); } diff --git a/test/Check/FunctionRequirementsCheckTest.php b/test/Check/FunctionRequirementsCheckTest.php index 852176f7..1488208f 100644 --- a/test/Check/FunctionRequirementsCheckTest.php +++ b/test/Check/FunctionRequirementsCheckTest.php @@ -39,12 +39,12 @@ class FunctionRequirementsCheckTest extends TestCase */ private $parser; - public function setUp() : void + public function setUp(): void { - $parserFactory = new ParserFactory; + $parserFactory = new ParserFactory(); $this->parser = $parserFactory->create(ParserFactory::PREFER_PHP7); $this->check = new FunctionRequirementsCheck($this->parser); - $this->exercise = new FunctionRequirementsExercise; + $this->exercise = new FunctionRequirementsExercise(); $this->assertEquals('Function Requirements Check', $this->check->getName()); $this->assertEquals(FunctionRequirementsExerciseCheck::class, $this->check->getExerciseInterface()); $this->assertEquals(SimpleCheckInterface::CHECK_AFTER, $this->check->getPosition()); @@ -53,7 +53,7 @@ public function setUp() : void $this->assertTrue($this->check->canRun(ExerciseType::CLI())); } - public function testExceptionIsThrownIfNotValidExercise() : void + public function testExceptionIsThrownIfNotValidExercise(): void { $exercise = $this->createMock(ExerciseInterface::class); $this->expectException(InvalidArgumentException::class); @@ -61,7 +61,7 @@ public function testExceptionIsThrownIfNotValidExercise() : void $this->check->check($exercise, new Input('app')); } - public function testFailureIsReturnedIfCodeCouldNotBeParsed() : void + public function testFailureIsReturnedIfCodeCouldNotBeParsed(): void { $file = __DIR__ . '/../res/function-requirements/fail-invalid-code.php'; $failure = $this->check->check($this->exercise, new Input('app', ['program' => $file])); @@ -71,7 +71,7 @@ public function testFailureIsReturnedIfCodeCouldNotBeParsed() : void $this->assertEquals($message, $failure->getReason()); } - public function testFailureIsReturnedIfBannedFunctionsAreUsed() : void + public function testFailureIsReturnedIfBannedFunctionsAreUsed(): void { $failure = $this->check->check( $this->exercise, @@ -82,7 +82,7 @@ public function testFailureIsReturnedIfBannedFunctionsAreUsed() : void $this->assertEquals([], $failure->getMissingFunctions()); } - public function testFailureIsReturnedIfNotAllRequiredFunctionsHaveBeenUsed() : void + public function testFailureIsReturnedIfNotAllRequiredFunctionsHaveBeenUsed(): void { $exercise = $this->createMock(FunctionRequirementsExercise::class); $exercise @@ -105,7 +105,7 @@ public function testFailureIsReturnedIfNotAllRequiredFunctionsHaveBeenUsed() : v $this->assertEquals([], $failure->getBannedFunctions()); } - public function testSuccess() : void + public function testSuccess(): void { $exercise = $this->createMock(FunctionRequirementsExercise::class); $exercise diff --git a/test/Check/PhpLintCheckTest.php b/test/Check/PhpLintCheckTest.php index 52b255ef..2824082e 100644 --- a/test/Check/PhpLintCheckTest.php +++ b/test/Check/PhpLintCheckTest.php @@ -25,7 +25,7 @@ class PhpLintCheckTest extends TestCase public function setUp(): void { - $this->check = new PhpLintCheck; + $this->check = new PhpLintCheck(); $this->exercise = $this->createMock(ExerciseInterface::class); $this->assertEquals('PHP Code Check', $this->check->getName()); $this->assertEquals(ExerciseInterface::class, $this->check->getExerciseInterface()); @@ -35,7 +35,7 @@ public function setUp(): void $this->assertTrue($this->check->canRun(ExerciseType::CLI())); } - public function testSuccess() : void + public function testSuccess(): void { $this->assertInstanceOf( Success::class, @@ -43,7 +43,7 @@ public function testSuccess() : void ); } - public function testFailure() : void + public function testFailure(): void { $failure = $this->check->check( $this->exercise, diff --git a/test/CodeInsertionTest.php b/test/CodeInsertionTest.php index de546d40..72a60398 100644 --- a/test/CodeInsertionTest.php +++ b/test/CodeInsertionTest.php @@ -13,19 +13,19 @@ */ class CodeInsertionTest extends TestCase { - public function testInvalidType() : void + public function testInvalidType(): void { $this->expectException(InvalidArgumentException::class); new CodeInsertion('notatype', ''); } - public function testInvalidCode() : void + public function testInvalidCode(): void { $this->expectException(InvalidArgumentException::class); - new CodeInsertion(CodeInsertion::TYPE_BEFORE, new \stdClass); + new CodeInsertion(CodeInsertion::TYPE_BEFORE, new \stdClass()); } - public function testGetters() : void + public function testGetters(): void { $mod = new CodeInsertion(CodeInsertion::TYPE_BEFORE, 'assertEquals(CodeInsertion::TYPE_BEFORE, $mod->getType()); diff --git a/test/CodePatcherTest.php b/test/CodePatcherTest.php index 2cfee5d4..a8fa9442 100644 --- a/test/CodePatcherTest.php +++ b/test/CodePatcherTest.php @@ -22,12 +22,12 @@ */ class CodePatcherTest extends TestCase { - public function testDefaultPatchIsAppliedIfAvailable() : void + public function testDefaultPatchIsAppliedIfAvailable(): void { - $patch = (new Patch) + $patch = (new Patch()) ->withInsertion(new Insertion(Insertion::TYPE_BEFORE, 'ini_set("display_errors", 1);')); - $patcher = new CodePatcher((new ParserFactory)->create(ParserFactory::PREFER_PHP7), new Standard, $patch); + $patcher = new CodePatcher((new ParserFactory())->create(ParserFactory::PREFER_PHP7), new Standard(), $patch); $exercise = $this->createMock(ExerciseInterface::class); $expected = "create(ParserFactory::PREFER_PHP7), new Standard); + $patcher = new CodePatcher((new ParserFactory())->create(ParserFactory::PREFER_PHP7), new Standard()); $exercise = $this->createMock(ExerciseInterface::class); $code = 'create(ParserFactory::PREFER_PHP7), new Standard); + $patcher = new CodePatcher((new ParserFactory())->create(ParserFactory::PREFER_PHP7), new Standard()); $exercise = $this->createMock(PatchableExercise::class); @@ -62,45 +62,45 @@ public function testPatcher(string $code, Patch $patch, string $expectedResult) $this->assertEquals($expectedResult, $result); } - public function codeProvider() : array + public function codeProvider(): array { return [ 'only-before-insertion' => [ 'withInsertion(new Insertion(Insertion::TYPE_BEFORE, '$before = "here";')), + (new Patch())->withInsertion(new Insertion(Insertion::TYPE_BEFORE, '$before = "here";')), " [ 'withInsertion(new Insertion(Insertion::TYPE_AFTER, '$after = "here";')), + (new Patch())->withInsertion(new Insertion(Insertion::TYPE_AFTER, '$after = "here";')), " [ 'withInsertion(new Insertion(Insertion::TYPE_BEFORE, '$before = "here";')) ->withInsertion(new Insertion(Insertion::TYPE_AFTER, '$after = "here";')), " [ 'withInsertion(new Insertion(Insertion::TYPE_BEFORE, '$before = "here"')), + (new Patch())->withInsertion(new Insertion(Insertion::TYPE_BEFORE, '$before = "here"')), //no semicolon at the end " [ 'withInsertion(new Insertion(Insertion::TYPE_BEFORE, 'withInsertion(new Insertion(Insertion::TYPE_BEFORE, ' [ 'withInsertion(new Insertion(Insertion::TYPE_BEFORE, ' withInsertion(new Insertion(Insertion::TYPE_BEFORE, ' [ 'withTransformer(function (array $statements) { return [ new TryCatch( @@ -113,7 +113,7 @@ public function codeProvider() : array ], 'transformer-with-before-insertion' => [ 'withInsertion(new Insertion(Insertion::TYPE_BEFORE, '$before = "here";')) ->withTransformer(function (array $statements) { return [ diff --git a/test/Command/CreditsCommandTest.php b/test/Command/CreditsCommandTest.php index acf1b968..9ca2b02e 100644 --- a/test/Command/CreditsCommandTest.php +++ b/test/Command/CreditsCommandTest.php @@ -17,11 +17,11 @@ class CreditsCommandTest extends TestCase { - public function testInvoke() : void + public function testInvoke(): void { $this->expectOutputString(file_get_contents(__DIR__ . '/../res/app-credits-expected.txt')); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $command = new CreditsCommand( @@ -42,11 +42,11 @@ public function testInvoke() : void $command->__invoke(); } - public function testWithOnlyCoreContributors() : void + public function testWithOnlyCoreContributors(): void { $this->expectOutputString(file_get_contents(__DIR__ . '/../res/app-credits-core-expected.txt')); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $command = new CreditsCommand( @@ -64,11 +64,11 @@ public function testWithOnlyCoreContributors() : void $command->__invoke(); } - public function testWithNoContributors() : void + public function testWithNoContributors(): void { $this->expectOutputString(''); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $command = new CreditsCommand( diff --git a/test/Command/HelpCommandTest.php b/test/Command/HelpCommandTest.php index 04ea014f..c079ba4f 100644 --- a/test/Command/HelpCommandTest.php +++ b/test/Command/HelpCommandTest.php @@ -15,11 +15,11 @@ */ class HelpCommandTest extends TestCase { - public function testInvoke() : void + public function testInvoke(): void { $this->expectOutputString(file_get_contents(__DIR__ . '/../res/app-help-expected.txt')); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $command = new HelpCommand( diff --git a/test/Command/MenuCommandInvokerTest.php b/test/Command/MenuCommandInvokerTest.php index 765b8b75..a435516e 100644 --- a/test/Command/MenuCommandInvokerTest.php +++ b/test/Command/MenuCommandInvokerTest.php @@ -13,7 +13,7 @@ */ class MenuCommandInvokerTest extends TestCase { - public function testInvoker() : void + public function testInvoker(): void { $menu = $this->createMock(CliMenu::class); $menu diff --git a/test/Command/MenuCommandTest.php b/test/Command/MenuCommandTest.php index a9903660..818269ff 100644 --- a/test/Command/MenuCommandTest.php +++ b/test/Command/MenuCommandTest.php @@ -1,6 +1,5 @@ createMock(CliMenu::class); $menu diff --git a/test/Command/PrintCommandTest.php b/test/Command/PrintCommandTest.php index 8779bf4e..6ed5e3ac 100644 --- a/test/Command/PrintCommandTest.php +++ b/test/Command/PrintCommandTest.php @@ -18,7 +18,7 @@ */ class PrintCommandTest extends TestCase { - public function testExerciseIsPrintedIfAssigned() : void + public function testExerciseIsPrintedIfAssigned(): void { $file = tempnam(sys_get_temp_dir(), 'pws'); file_put_contents($file, '### Exercise 1'); @@ -30,7 +30,7 @@ public function testExerciseIsPrintedIfAssigned() : void $repo = new ExerciseRepository([$exercise->reveal()]); - $state = new UserState; + $state = new UserState(); $state->setCurrentExercise('some-exercise'); $output = $this->createMock(OutputInterface::class); diff --git a/test/Command/RunCommandTest.php b/test/Command/RunCommandTest.php index 272d2bd0..c3bcc75d 100644 --- a/test/Command/RunCommandTest.php +++ b/test/Command/RunCommandTest.php @@ -18,16 +18,16 @@ */ class RunCommandTest extends TestCase { - public function test() : void + public function test(): void { $input = new Input('appName', ['program' => 'solution.php']); - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $repo = new ExerciseRepository([$exercise]); - $state = new UserState; + $state = new UserState(); $state->setCurrentExercise('my-exercise'); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); diff --git a/test/Command/VerifyCommandTest.php b/test/Command/VerifyCommandTest.php index bbc6e990..77c7b714 100644 --- a/test/Command/VerifyCommandTest.php +++ b/test/Command/VerifyCommandTest.php @@ -32,7 +32,7 @@ class VerifyCommandTest extends TestCase */ private $check; - public function setUp() : void + public function setUp(): void { $this->check = $this->createMock(CheckInterface::class); $this->check @@ -40,19 +40,19 @@ public function setUp() : void ->willReturn('Some Check'); } - public function testVerifyAddsCompletedExerciseAndReturnsCorrectCodeOnSuccess() : void + public function testVerifyAddsCompletedExerciseAndReturnsCorrectCodeOnSuccess(): void { $file = tempnam(sys_get_temp_dir(), 'pws'); touch($file); $input = new Input('appName', ['program' => $file]); - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $repo = new ExerciseRepository([$exercise]); - $state = new UserState; + $state = new UserState(); $state->setCurrentExercise('my-exercise'); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); @@ -64,7 +64,7 @@ public function testVerifyAddsCompletedExerciseAndReturnsCorrectCodeOnSuccess() $renderer = $this->createMock(ResultsRenderer::class); - $results = new ResultAggregator; + $results = new ResultAggregator(); $results->add(new Success($this->check)); $dispatcher = $this->createMock(ExerciseDispatcher::class); @@ -87,18 +87,18 @@ public function testVerifyAddsCompletedExerciseAndReturnsCorrectCodeOnSuccess() unlink($file); } - public function testVerifyDoesNotAddCompletedExerciseAndReturnsCorrectCodeOnFailure() : void + public function testVerifyDoesNotAddCompletedExerciseAndReturnsCorrectCodeOnFailure(): void { $file = tempnam(sys_get_temp_dir(), 'pws'); touch($file); $input = new Input('appName', ['program' => $file]); - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $repo = new ExerciseRepository([$exercise]); - $state = new UserState; + $state = new UserState(); $state->setCurrentExercise('my-exercise'); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); @@ -111,7 +111,7 @@ public function testVerifyDoesNotAddCompletedExerciseAndReturnsCorrectCodeOnFail $renderer = $this->createMock(ResultsRenderer::class); - $results = new ResultAggregator; + $results = new ResultAggregator(); $results->add(new Failure($this->check, 'cba')); $dispatcher = $this->createMock(ExerciseDispatcher::class); diff --git a/test/CommandArgumentTest.php b/test/CommandArgumentTest.php index 113332c0..f64c3595 100644 --- a/test/CommandArgumentTest.php +++ b/test/CommandArgumentTest.php @@ -10,14 +10,14 @@ */ class CommandArgumentTest extends TestCase { - public function testRequiredArgument() : void + public function testRequiredArgument(): void { $arg = new CommandArgument('arg1'); $this->assertSame('arg1', $arg->getName()); $this->assertFalse($arg->isOptional()); } - public function testOptionalArgument() : void + public function testOptionalArgument(): void { $arg = new CommandArgument('arg1', true); $this->assertSame('arg1', $arg->getName()); diff --git a/test/CommandDefinitionTest.php b/test/CommandDefinitionTest.php index 15812dfb..15e97a6c 100644 --- a/test/CommandDefinitionTest.php +++ b/test/CommandDefinitionTest.php @@ -13,7 +13,7 @@ class CommandDefinitionTest extends TestCase { - public function testGettersSettersWithStringArgs() : void + public function testGettersSettersWithStringArgs(): void { $callable = function () { }; @@ -29,7 +29,7 @@ public function testGettersSettersWithStringArgs() : void $this->assertSame($callable, $definition->getCommandCallable()); } - public function testGettersSettersWithObjArgs() : void + public function testGettersSettersWithObjArgs(): void { $callable = function () { }; @@ -45,7 +45,7 @@ public function testGettersSettersWithObjArgs() : void $this->assertSame($callable, $definition->getCommandCallable()); } - public function testExceptionIsThrowWhenTryingToAddRequiredArgAfterOptionalArg() : void + public function testExceptionIsThrowWhenTryingToAddRequiredArgAfterOptionalArg(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A required argument cannot follow an optional argument'); @@ -56,7 +56,7 @@ public function testExceptionIsThrowWhenTryingToAddRequiredArgAfterOptionalArg() ->addArgument(CommandArgument::required('required-arg')); } - public function testExceptionIsThrownWithWrongParameterToAddArgument() : void + public function testExceptionIsThrownWithWrongParameterToAddArgument(): void { $this->expectException(InvalidArgumentException::class); $msg = 'Parameter: "argument" can only be one of: "string", "PhpSchool\PhpWorkshop\CommandArgument" '; @@ -64,6 +64,6 @@ public function testExceptionIsThrownWithWrongParameterToAddArgument() : void $this->expectExceptionMessage($msg); $definition = new CommandDefinition('animal', [], 'strlen'); - $definition->addArgument(new \stdClass); + $definition->addArgument(new \stdClass()); } } diff --git a/test/CommandRouterTest.php b/test/CommandRouterTest.php index 1b2876bf..f1bf1fa1 100644 --- a/test/CommandRouterTest.php +++ b/test/CommandRouterTest.php @@ -21,7 +21,7 @@ */ class CommandRouterTest extends TestCase { - public function testInvalidDefaultThrowsException() : void + public function testInvalidDefaultThrowsException(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Default command: "cmd" is not available'); @@ -31,7 +31,7 @@ public function testInvalidDefaultThrowsException() : void new CommandRouter([], 'cmd', $eventDispatcher, $c); } - public function testAddCommandThrowsExceptionIfCommandWithSameNameExists() : void + public function testAddCommandThrowsExceptionIfCommandWithSameNameExists(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Command with name: "cmd" already exists'); @@ -44,7 +44,7 @@ public function testAddCommandThrowsExceptionIfCommandWithSameNameExists() : voi ], 'default', $eventDispatcher, $c); } - public function testRouteCommandWithNoArgsFromArrayUsesDefaultCommand() : void + public function testRouteCommandWithNoArgsFromArrayUsesDefaultCommand(): void { $args = ['app']; @@ -63,7 +63,7 @@ public function testRouteCommandWithNoArgsFromArrayUsesDefaultCommand() : void $router->route($args); } - public function testRouteCommandWithNoArgsFromArgVUsesDefaultCommand() : void + public function testRouteCommandWithNoArgsFromArgVUsesDefaultCommand(): void { $server = $_SERVER; $_SERVER['argv'] = ['app']; @@ -83,7 +83,7 @@ public function testRouteCommandWithNoArgsFromArgVUsesDefaultCommand() : void $_SERVER = $server; } - public function testRouteCommandThrowsExceptionIfCommandWithNameNotExist() : void + public function testRouteCommandThrowsExceptionIfCommandWithNameNotExist(): void { $this->expectException(CliRouteNotExistsException::class); $this->expectExceptionMessage('Command: "not-a-cmd" does not exist'); @@ -96,7 +96,7 @@ public function testRouteCommandThrowsExceptionIfCommandWithNameNotExist() : voi $router->route(['app', 'not-a-cmd']); } - public function testRouteCommandThrowsExceptionIfCommandIsMissingAllArguments() : void + public function testRouteCommandThrowsExceptionIfCommandIsMissingAllArguments(): void { $this->expectException(MissingArgumentException::class); $this->expectExceptionMessage('Command: "verify" is missing the following arguments: "exercise", "program"'); @@ -113,7 +113,7 @@ public function testRouteCommandThrowsExceptionIfCommandIsMissingAllArguments() $router->route(['app', 'verify']); } - public function testRouteCommandThrowsExceptionIfCommandIsMissingArguments() : void + public function testRouteCommandThrowsExceptionIfCommandIsMissingArguments(): void { $this->expectException(MissingArgumentException::class); $this->expectExceptionMessage('Command: "verify" is missing the following arguments: "program"'); @@ -130,7 +130,7 @@ public function testRouteCommandThrowsExceptionIfCommandIsMissingArguments() : v $router->route(['app', 'verify', 'some-exercise']); } - public function testRouteCommandWithArgs() : void + public function testRouteCommandWithArgs(): void { $mock = $this->getMockBuilder('stdClass') ->setMethods(['__invoke']) @@ -156,7 +156,7 @@ public function testRouteCommandWithArgs() : void $router->route(['app', 'verify', 'some-exercise', 'program.php']); } - public function testExceptionIsThrownIfCallableNotCallableAndNotContainerReference() : void + public function testExceptionIsThrownIfCallableNotCallableAndNotContainerReference(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Callable must be a callable or a container entry for a callable service'); @@ -164,7 +164,7 @@ public function testExceptionIsThrownIfCallableNotCallableAndNotContainerReferen $c = $this->createMock(ContainerInterface::class); $eventDispatcher = $this->createMock(EventDispatcher::class); $router = new CommandRouter( - [new CommandDefinition('verify', ['exercise', 'program'], new \stdClass),], + [new CommandDefinition('verify', ['exercise', 'program'], new \stdClass()),], 'verify', $eventDispatcher, $c @@ -172,7 +172,7 @@ public function testExceptionIsThrownIfCallableNotCallableAndNotContainerReferen $router->route(['app', 'verify', 'some-exercise', 'program.php']); } - public function testExceptionIsThrownIfCallableNotCallableAndNotExistingContainerEntry() : void + public function testExceptionIsThrownIfCallableNotCallableAndNotExistingContainerEntry(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Container has no entry named: "some.service"'); @@ -195,7 +195,7 @@ public function testExceptionIsThrownIfCallableNotCallableAndNotExistingContaine $router->route(['app', 'verify', 'some-exercise', 'program.php']); } - public function testExceptionIsThrownIfContainerEntryNotCallable() : void + public function testExceptionIsThrownIfContainerEntryNotCallable(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Container entry: "some.service" not callable'); @@ -224,7 +224,7 @@ public function testExceptionIsThrownIfContainerEntryNotCallable() : void $router->route(['app', 'verify', 'some-exercise', 'program.php']); } - public function testCallableFromContainer() : void + public function testCallableFromContainer(): void { $c = $this->createMock(ContainerInterface::class); @@ -264,7 +264,7 @@ public function testCallableFromContainer() : void $router->route(['app', 'verify', 'some-exercise', 'program.php']); } - public function testCallableFromContainerWithIntegerReturnCode() : void + public function testCallableFromContainerWithIntegerReturnCode(): void { $c = $this->createMock(ContainerInterface::class); @@ -305,7 +305,7 @@ public function testCallableFromContainerWithIntegerReturnCode() : void $this->assertEquals(10, $res); } - public function testRouteCommandSpeltIncorrectlyStillRoutes() : void + public function testRouteCommandSpeltIncorrectlyStillRoutes(): void { $mock = $this->getMockBuilder('stdClass') ->setMethods(['__invoke']) @@ -332,7 +332,7 @@ public function testRouteCommandSpeltIncorrectlyStillRoutes() : void $router->route(['app', 'verifu', 'some-exercise', 'program.php']); } - public function testRouteCommandWithOptionalArgument() : void + public function testRouteCommandWithOptionalArgument(): void { $mock = $this->getMockBuilder('stdClass') ->setMethods(['__invoke']) diff --git a/test/ComposerUtil/LockFileParserTest.php b/test/ComposerUtil/LockFileParserTest.php index 916497f1..46dce4ca 100644 --- a/test/ComposerUtil/LockFileParserTest.php +++ b/test/ComposerUtil/LockFileParserTest.php @@ -12,7 +12,7 @@ */ class LockFileParserTest extends TestCase { - public function testGetPackages() : void + public function testGetPackages(): void { $locker = new LockFileParser(__DIR__ . '/../res/composer.lock'); $this->assertEquals([ @@ -21,7 +21,7 @@ public function testGetPackages() : void ], $locker->getInstalledPackages()); } - public function testHasPackage() : void + public function testHasPackage(): void { $locker = new LockFileParser(__DIR__ . '/../res/composer.lock'); $this->assertTrue($locker->hasInstalledPackage('danielstjules/stringy')); @@ -29,7 +29,7 @@ public function testHasPackage() : void $this->assertFalse($locker->hasInstalledPackage('not-a-package')); } - public function testExceptionIsThrownIfFileNotExists() : void + public function testExceptionIsThrownIfFileNotExists(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Lock File: "not-a-file" does not exist'); diff --git a/test/Event/CgiExecuteEventTest.php b/test/Event/CgiExecuteEventTest.php index fbe8920a..8380e832 100644 --- a/test/Event/CgiExecuteEventTest.php +++ b/test/Event/CgiExecuteEventTest.php @@ -14,9 +14,9 @@ */ class CgiExecuteEventTest extends TestCase { - public function testAddHeader() : void + public function testAddHeader(): void { - $request = new Request; + $request = new Request(); $e = new CgiExecuteEvent('event', $request); $e->addHeaderToRequest('Content-Type', 'text/html'); @@ -24,9 +24,9 @@ public function testAddHeader() : void $this->assertNotSame($request, $e->getRequest()); } - public function testModifyRequest() : void + public function testModifyRequest(): void { - $request = new Request; + $request = new Request(); $e = new CgiExecuteEvent('event', $request); $e->modifyRequest(function (RequestInterface $request) { @@ -39,9 +39,9 @@ public function testModifyRequest() : void $this->assertNotSame($request, $e->getRequest()); } - public function testGetRequest() : void + public function testGetRequest(): void { - $request = new Request; + $request = new Request(); $e = new CgiExecuteEvent('event', $request); $this->assertSame($request, $e->getRequest()); diff --git a/test/Event/CliExecuteEventTest.php b/test/Event/CliExecuteEventTest.php index 382c3d63..da98048f 100644 --- a/test/Event/CliExecuteEventTest.php +++ b/test/Event/CliExecuteEventTest.php @@ -13,7 +13,7 @@ */ class CliExecuteEventTest extends TestCase { - public function testAppendArg() : void + public function testAppendArg(): void { $arr = new ArrayObject([1, 2, 3]); $e = new CliExecuteEvent('event', $arr); @@ -23,7 +23,7 @@ public function testAppendArg() : void $this->assertNotSame($arr, $e->getArgs()); } - public function testPrependArg() : void + public function testPrependArg(): void { $arr = new ArrayObject([1, 2, 3]); $e = new CliExecuteEvent('event', $arr); @@ -33,7 +33,7 @@ public function testPrependArg() : void $this->assertNotSame($arr, $e->getArgs()); } - public function testGetArgs() : void + public function testGetArgs(): void { $arr = new ArrayObject([1, 2, 3]); $e = new CliExecuteEvent('event', $arr); diff --git a/test/Event/ContainerListenerHelperTest.php b/test/Event/ContainerListenerHelperTest.php index 4d102945..2048b77c 100644 --- a/test/Event/ContainerListenerHelperTest.php +++ b/test/Event/ContainerListenerHelperTest.php @@ -10,7 +10,7 @@ */ class ContainerListenerHelperTest extends TestCase { - public function testDefaultMethodIsInvoke() : void + public function testDefaultMethodIsInvoke(): void { $helper = new ContainerListenerHelper('Some\Object'); @@ -18,7 +18,7 @@ public function testDefaultMethodIsInvoke() : void $this->assertEquals('__invoke', $helper->getMethod()); } - public function testWithCustomMethod() : void + public function testWithCustomMethod(): void { $helper = new ContainerListenerHelper('Some\Object', 'myMethod'); diff --git a/test/Event/EventDispatcherTest.php b/test/Event/EventDispatcherTest.php index 641eac6b..10c8c238 100644 --- a/test/Event/EventDispatcherTest.php +++ b/test/Event/EventDispatcherTest.php @@ -26,13 +26,13 @@ class EventDispatcherTest extends TestCase */ private $eventDispatcher; - public function setUp() : void + public function setUp(): void { - $this->results = new ResultAggregator; + $this->results = new ResultAggregator(); $this->eventDispatcher = new EventDispatcher($this->results); } - public function testOnlyAppropriateListenersAreCalledForEvent() : void + public function testOnlyAppropriateListenersAreCalledForEvent(): void { $e = new Event('some-event', ['arg1' => 1, 'arg2' => 2]); $mockCallback1 = $this->getMockBuilder('stdClass') @@ -63,7 +63,7 @@ public function testOnlyAppropriateListenersAreCalledForEvent() : void $this->eventDispatcher->dispatch($e); } - public function testOnlyAppropriateVerifiersAreCalledForEvent() : void + public function testOnlyAppropriateVerifiersAreCalledForEvent(): void { $e = new Event('some-event', ['arg1' => 1, 'arg2' => 2]); $result = $this->createMock(ResultInterface::class); @@ -88,7 +88,7 @@ public function testOnlyAppropriateVerifiersAreCalledForEvent() : void $this->assertEquals([$result, $result], iterator_to_array($this->results)); } - public function testVerifyReturnIsSkippedIfNotInstanceOfResult() : void + public function testVerifyReturnIsSkippedIfNotInstanceOfResult(): void { $e = new Event('some-event', ['arg1' => 1, 'arg2' => 2]); $mockCallback1 = $this->getMockBuilder('stdClass') @@ -108,7 +108,7 @@ public function testVerifyReturnIsSkippedIfNotInstanceOfResult() : void $this->assertEquals([], iterator_to_array($this->results)); } - public function testListenWithMultipleEvents() : void + public function testListenWithMultipleEvents(): void { $e1 = new Event('some-event', ['arg1' => 1, 'arg2' => 2]); $e2 = new Event('some-event', ['arg1' => 1, 'arg2' => 2]); @@ -126,7 +126,7 @@ public function testListenWithMultipleEvents() : void $this->eventDispatcher->dispatch($e2); } - public function testListenersAndVerifiersAreCalledInOrderOfAttachment() : void + public function testListenersAndVerifiersAreCalledInOrderOfAttachment(): void { $e1 = new Event('first-event', ['arg1' => 1, 'arg2' => 2]); diff --git a/test/Event/EventTest.php b/test/Event/EventTest.php index 80402996..12420089 100644 --- a/test/Event/EventTest.php +++ b/test/Event/EventTest.php @@ -13,20 +13,20 @@ */ class EventTest extends TestCase { - public function testGetName() : void + public function testGetName(): void { $e = new Event('super-sweet-event!'); $this->assertEquals('super-sweet-event!', $e->getName()); } - public function testGetParameters() : void + public function testGetParameters(): void { $e = new Event('super-sweet-event-with-cool-params', ['cool' => 'stuff']); $this->assertEquals('stuff', $e->getParameter('cool')); $this->assertEquals(['cool' => 'stuff'], $e->getParameters()); } - public function testExeceptionIsThrownIfParameterDoesNotExist() : void + public function testExeceptionIsThrownIfParameterDoesNotExist(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Parameter: "cool" does not exist'); diff --git a/test/Event/ExerciseRunnerEventTest.php b/test/Event/ExerciseRunnerEventTest.php index d9dc3a90..a2810202 100644 --- a/test/Event/ExerciseRunnerEventTest.php +++ b/test/Event/ExerciseRunnerEventTest.php @@ -12,9 +12,9 @@ */ class ExerciseRunnerEventTest extends TestCase { - public function testGetters() : void + public function testGetters(): void { - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $input = new Input('app'); $event = new ExerciseRunnerEvent('Some Event', $exercise, $input, ['number' => 1]); diff --git a/test/Exception/CheckNotApplicableExceptionTest.php b/test/Exception/CheckNotApplicableExceptionTest.php index 82f2e03e..362a3385 100644 --- a/test/Exception/CheckNotApplicableExceptionTest.php +++ b/test/Exception/CheckNotApplicableExceptionTest.php @@ -15,13 +15,13 @@ */ class CheckNotApplicableExceptionTest extends TestCase { - public function testException() : void + public function testException(): void { $e = new CheckNotApplicableException('nope'); $this->assertEquals('nope', $e->getMessage()); } - public function testFromCheckAndExerciseConstructor() : void + public function testFromCheckAndExerciseConstructor(): void { $exercise = $this->createMock(ExerciseInterface::class); $exercise diff --git a/test/Exception/CliRouteNotExistsTest.php b/test/Exception/CliRouteNotExistsTest.php index 946d0d05..272bf1d6 100644 --- a/test/Exception/CliRouteNotExistsTest.php +++ b/test/Exception/CliRouteNotExistsTest.php @@ -12,7 +12,7 @@ */ class CliRouteNotExistsTest extends TestCase { - public function testException() : void + public function testException(): void { $e = new CliRouteNotExistsException('some-route'); $this->assertEquals('Command: "some-route" does not exist', $e->getMessage()); diff --git a/test/Exception/CodeExecutionExceptionTest.php b/test/Exception/CodeExecutionExceptionTest.php index bb64466c..0b6cdf64 100644 --- a/test/Exception/CodeExecutionExceptionTest.php +++ b/test/Exception/CodeExecutionExceptionTest.php @@ -13,13 +13,13 @@ */ class CodeExecutionExceptionTest extends TestCase { - public function testException() : void + public function testException(): void { $e = new CodeExecutionException('nope'); $this->assertEquals('nope', $e->getMessage()); } - public function testFromProcessUsesErrorOutputIfNotEmpty() : void + public function testFromProcessUsesErrorOutputIfNotEmpty(): void { $process = $this->createMock(Process::class); @@ -32,7 +32,7 @@ public function testFromProcessUsesErrorOutputIfNotEmpty() : void $this->assertEquals('PHP Code failed to execute. Error: "Error Output"', $e->getMessage()); } - public function testFromProcessUsesStdOutputIfErrorOutputEmpty() : void + public function testFromProcessUsesStdOutputIfErrorOutputEmpty(): void { $process = $this->createMock(Process::class); $process diff --git a/test/Exception/ExerciseNotConfiguredExceptionTest.php b/test/Exception/ExerciseNotConfiguredExceptionTest.php index 72ac028b..70be2d81 100644 --- a/test/Exception/ExerciseNotConfiguredExceptionTest.php +++ b/test/Exception/ExerciseNotConfiguredExceptionTest.php @@ -13,13 +13,13 @@ */ class ExerciseNotConfiguredExceptionTest extends TestCase { - public function testException() : void + public function testException(): void { $e = new ExerciseNotConfiguredException('nope'); $this->assertEquals('nope', $e->getMessage()); } - public function testMissingImplementsConstructor() : void + public function testMissingImplementsConstructor(): void { $exercise = $this->createMock(ExerciseInterface::class); $exercise diff --git a/test/Exception/InvalidArgumentExceptionTest.php b/test/Exception/InvalidArgumentExceptionTest.php index df48b411..904e3c86 100644 --- a/test/Exception/InvalidArgumentExceptionTest.php +++ b/test/Exception/InvalidArgumentExceptionTest.php @@ -13,34 +13,34 @@ */ class InvalidArgumentExceptionTest extends TestCase { - public function testException() : void + public function testException(): void { $e = new InvalidArgumentException('nope'); $this->assertEquals('nope', $e->getMessage()); } - public function testExceptionFromTypeMisMatchConstructor() : void + public function testExceptionFromTypeMisMatchConstructor(): void { - $e = InvalidArgumentException::typeMisMatch('string', new \stdClass); + $e = InvalidArgumentException::typeMisMatch('string', new \stdClass()); $this->assertEquals('Expected: "string" Received: "stdClass"', $e->getMessage()); } - public function testExceptionFromNotValidParameterConstructor() : void + public function testExceptionFromNotValidParameterConstructor(): void { $e = InvalidArgumentException::notValidParameter('number', [1, 2], 3); $this->assertEquals('Parameter: "number" can only be one of: "1", "2" Received: "3"', $e->getMessage()); } - public function testExceptionFromMissingImplements() : void + public function testExceptionFromMissingImplements(): void { - $e = InvalidArgumentException::missingImplements(new \stdClass, Countable::class); + $e = InvalidArgumentException::missingImplements(new \stdClass(), Countable::class); self::assertEquals('"stdClass" is required to implement "Countable", but it does not', $e->getMessage()); } /** * @dataProvider stringifyProvider */ - public function testStringify($value, string $expected) : void + public function testStringify($value, string $expected): void { $rM = new \ReflectionMethod(InvalidArgumentException::class, 'stringify'); $rM->setAccessible(true); @@ -48,10 +48,10 @@ public function testStringify($value, string $expected) : void $this->assertEquals($rM->invoke(null, $value), $expected); } - public function stringifyProvider() : array + public function stringifyProvider(): array { return [ - [new \stdClass, 'stdClass'], + [new \stdClass(), 'stdClass'], [[1, 2, 3], '1", "2", "3'], [1, '1'], ['1', '1'], diff --git a/test/Exception/MissingArgumentExceptionTest.php b/test/Exception/MissingArgumentExceptionTest.php index 42c40574..0be32cc4 100644 --- a/test/Exception/MissingArgumentExceptionTest.php +++ b/test/Exception/MissingArgumentExceptionTest.php @@ -12,7 +12,7 @@ */ class MissingArgumentExceptionTest extends TestCase { - public function testException() : void + public function testException(): void { $e = new MissingArgumentException('some-route', ['arg1', 'arg2']); $this->assertEquals( diff --git a/test/Exception/SolutionExecutionExceptionTest.php b/test/Exception/SolutionExecutionExceptionTest.php index 358e403c..e1c19bd0 100644 --- a/test/Exception/SolutionExecutionExceptionTest.php +++ b/test/Exception/SolutionExecutionExceptionTest.php @@ -12,7 +12,7 @@ */ class SolutionExecutionExceptionTest extends TestCase { - public function testException() : void + public function testException(): void { $e = new SolutionExecutionException('nope'); $this->assertEquals('nope', $e->getMessage()); diff --git a/test/Exercise/AbstractExerciseTest.php b/test/Exercise/AbstractExerciseTest.php index a4cd57ab..4311a51f 100644 --- a/test/Exercise/AbstractExerciseTest.php +++ b/test/Exercise/AbstractExerciseTest.php @@ -16,7 +16,7 @@ */ class AbstractExerciseTest extends TestCase { - public function testTearDownReturnsVoid() : void + public function testTearDownReturnsVoid(): void { $exercise = new AbstractExerciseImpl('name'); $this->assertNull($exercise->tearDown()); @@ -25,7 +25,7 @@ public function testTearDownReturnsVoid() : void /** * @dataProvider solutionProvider */ - public function testGetSolution(string $name) : void + public function testGetSolution(string $name): void { $exercise = new AbstractExerciseImpl($name); $path = __DIR__ . '/../../exercises/array-we-go/solution/solution.php'; @@ -43,7 +43,7 @@ public function testGetSolution(string $name) : void rmdir(__DIR__ . '/../../exercises'); } - public function solutionProvider() : array + public function solutionProvider(): array { return [ ['Array We Go!'], @@ -55,13 +55,13 @@ public function solutionProvider() : array /** * @dataProvider problemProvider */ - public function testGetProblem(string $name, string $path) : void + public function testGetProblem(string $name, string $path): void { $exercise = new AbstractExerciseImpl($name); $this->assertSame($path, $exercise->getProblem()); } - public function problemProvider() : array + public function problemProvider(): array { $reflector = new ReflectionClass(AbstractExerciseImpl::class); $dir = dirname($reflector->getFileName()); @@ -72,7 +72,7 @@ public function problemProvider() : array ]; } - public function testConfigureDoesNothing() : void + public function testConfigureDoesNothing(): void { $dispatcher = $this->createMock(ExerciseDispatcher::class); diff --git a/test/Exercise/TemporaryDirectoryTraitTest.php b/test/Exercise/TemporaryDirectoryTraitTest.php index 6c45076c..babd0d32 100644 --- a/test/Exercise/TemporaryDirectoryTraitTest.php +++ b/test/Exercise/TemporaryDirectoryTraitTest.php @@ -12,9 +12,9 @@ */ class TemporaryDirectoryTraitTest extends TestCase { - public function testGetTemporaryPath() : void + public function testGetTemporaryPath(): void { - $impl = new TemporaryDirectoryTraitImpl; + $impl = new TemporaryDirectoryTraitImpl(); $path = $impl->getTemporaryPath(); mkdir($path, 0775, true); diff --git a/test/ExerciseDispatcherTest.php b/test/ExerciseDispatcherTest.php index 7743cbc3..19fba460 100644 --- a/test/ExerciseDispatcherTest.php +++ b/test/ExerciseDispatcherTest.php @@ -38,43 +38,43 @@ class ExerciseDispatcherTest extends TestCase */ private $file; - public function setUp() : void + public function setUp(): void { - $this->filesystem = new Filesystem; + $this->filesystem = new Filesystem(); $this->file = sprintf('%s/%s/submission.php', str_replace('\\', '/', sys_get_temp_dir()), $this->getName()); mkdir(dirname($this->file), 0775, true); touch($this->file); } - public function testGetEventDispatcher() : void + public function testGetEventDispatcher(): void { - $eventDispatcher = new EventDispatcher($results = new ResultAggregator); + $eventDispatcher = new EventDispatcher($results = new ResultAggregator()); $exerciseDispatcher = new ExerciseDispatcher( $this->prophesize(RunnerManager::class)->reveal(), $results, $eventDispatcher, - new CheckRepository + new CheckRepository() ); $this->assertSame($eventDispatcher, $exerciseDispatcher->getEventDispatcher()); } - public function testRequireCheckThrowsExceptionIfCheckDoesNotExist() : void + public function testRequireCheckThrowsExceptionIfCheckDoesNotExist(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Check: "NotACheck" does not exist'); $exerciseDispatcher = new ExerciseDispatcher( $this->prophesize(RunnerManager::class)->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), - new CheckRepository + new CheckRepository() ); $exerciseDispatcher->requireCheck('NotACheck'); } - public function testRequireCheckThrowsExceptionIfPositionNotValid() : void + public function testRequireCheckThrowsExceptionIfPositionNotValid(): void { $checkProphecy = $this->prophesize(SimpleCheckInterface::class); $checkProphecy->getName()->willReturn('Some Check'); @@ -84,7 +84,7 @@ public function testRequireCheckThrowsExceptionIfPositionNotValid() : void $exerciseDispatcher = new ExerciseDispatcher( $this->prophesize(RunnerManager::class)->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check]) ); @@ -94,7 +94,7 @@ public function testRequireCheckThrowsExceptionIfPositionNotValid() : void $exerciseDispatcher->requireCheck(get_class($check)); } - public function testRequireBeforeCheckIsCorrectlyRegistered() : void + public function testRequireBeforeCheckIsCorrectlyRegistered(): void { $checkProphecy = $this->prophesize(SimpleCheckInterface::class); $checkProphecy->getName()->willReturn('Some Check'); @@ -104,7 +104,7 @@ public function testRequireBeforeCheckIsCorrectlyRegistered() : void $exerciseDispatcher = new ExerciseDispatcher( $this->prophesize(RunnerManager::class)->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check]) ); @@ -113,7 +113,7 @@ public function testRequireBeforeCheckIsCorrectlyRegistered() : void $this->assertEquals([$check], $exerciseDispatcher->getChecksToRunBefore()); } - public function testRequireAfterCheckIsCorrectlyRegistered() : void + public function testRequireAfterCheckIsCorrectlyRegistered(): void { $checkProphecy = $this->prophesize(SimpleCheckInterface::class); $checkProphecy->getName()->willReturn('Some Check'); @@ -123,7 +123,7 @@ public function testRequireAfterCheckIsCorrectlyRegistered() : void $exerciseDispatcher = new ExerciseDispatcher( $this->prophesize(RunnerManager::class)->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check]) ); @@ -132,7 +132,7 @@ public function testRequireAfterCheckIsCorrectlyRegistered() : void $this->assertEquals([$check], $exerciseDispatcher->getChecksToRunAfter()); } - public function testRequireCheckThrowsExceptionIfCheckIsNotSimpleOrListenable() : void + public function testRequireCheckThrowsExceptionIfCheckIsNotSimpleOrListenable(): void { $checkProphecy = $this->prophesize(CheckInterface::class); $checkProphecy->getName()->willReturn('Some Check'); @@ -141,7 +141,7 @@ public function testRequireCheckThrowsExceptionIfCheckIsNotSimpleOrListenable() $exerciseDispatcher = new ExerciseDispatcher( $this->prophesize(RunnerManager::class)->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check]) ); @@ -151,7 +151,7 @@ public function testRequireCheckThrowsExceptionIfCheckIsNotSimpleOrListenable() $exerciseDispatcher->requireCheck(get_class($check)); } - public function testRequireListenableCheckAttachesToDispatcher() : void + public function testRequireListenableCheckAttachesToDispatcher(): void { $eventDispatcher = $this->prophesize(EventDispatcher::class)->reveal(); $checkProphecy = $this->prophesize(ListenableCheckInterface::class); @@ -160,7 +160,7 @@ public function testRequireListenableCheckAttachesToDispatcher() : void $exerciseDispatcher = new ExerciseDispatcher( $this->prophesize(RunnerManager::class)->reveal(), - new ResultAggregator, + new ResultAggregator(), $eventDispatcher, new CheckRepository([$check]) ); @@ -168,7 +168,7 @@ public function testRequireListenableCheckAttachesToDispatcher() : void $exerciseDispatcher->requireCheck(get_class($check)); } - public function testVerifyThrowsExceptionIfCheckDoesNotSupportExerciseType() : void + public function testVerifyThrowsExceptionIfCheckDoesNotSupportExerciseType(): void { $exercise = new CliExerciseImpl('Some Exercise'); @@ -186,7 +186,7 @@ public function testVerifyThrowsExceptionIfCheckDoesNotSupportExerciseType() : v $exerciseDispatcher = new ExerciseDispatcher( $runnerManager->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check]) ); @@ -198,7 +198,7 @@ public function testVerifyThrowsExceptionIfCheckDoesNotSupportExerciseType() : v $exerciseDispatcher->verify($exercise, new Input('app')); } - public function testVerifyThrowsExceptionIfExerciseDoesNotImplementCorrectInterface() : void + public function testVerifyThrowsExceptionIfExerciseDoesNotImplementCorrectInterface(): void { $exercise = new CliExerciseImpl('Some Exercise'); @@ -216,7 +216,7 @@ public function testVerifyThrowsExceptionIfExerciseDoesNotImplementCorrectInterf $exerciseDispatcher = new ExerciseDispatcher( $runnerManager->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check]) ); @@ -228,7 +228,7 @@ public function testVerifyThrowsExceptionIfExerciseDoesNotImplementCorrectInterf $exerciseDispatcher->verify($exercise, new Input('app')); } - public function testVerify() : void + public function testVerify(): void { $input = new Input('app', ['program' => $this->file]); $exercise = new CliExerciseImpl('Some Exercise'); @@ -249,7 +249,7 @@ public function testVerify() : void $exerciseDispatcher = new ExerciseDispatcher( $runnerManager->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check]) ); @@ -259,7 +259,7 @@ public function testVerify() : void $this->assertTrue($result->isSuccessful()); } - public function testVerifyOnlyRunsRequiredChecks() : void + public function testVerifyOnlyRunsRequiredChecks(): void { $input = new Input('app', ['program' => $this->file]); $exercise = new CliExerciseImpl('Some Exercise'); @@ -315,7 +315,7 @@ public function testVerifyOnlyRunsRequiredChecks() : void $exerciseDispatcher = new ExerciseDispatcher( $runnerManager, - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check1, $check2]) ); @@ -325,7 +325,7 @@ public function testVerifyOnlyRunsRequiredChecks() : void $this->assertTrue($result->isSuccessful()); } - public function testVerifyWithBeforeAndAfterRequiredChecks() : void + public function testVerifyWithBeforeAndAfterRequiredChecks(): void { $input = new Input('app', ['program' => $this->file]); $exercise = new CliExerciseImpl('Some Exercise'); @@ -353,7 +353,7 @@ public function testVerifyWithBeforeAndAfterRequiredChecks() : void $exerciseDispatcher = new ExerciseDispatcher( $runnerManager->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check1, $check2]) ); @@ -365,7 +365,7 @@ public function testVerifyWithBeforeAndAfterRequiredChecks() : void } - public function testWhenBeforeChecksFailTheyReturnImmediately() : void + public function testWhenBeforeChecksFailTheyReturnImmediately(): void { $input = new Input('app', ['program' => $this->file]); $exercise = new CliExerciseImpl('Some Exercise'); @@ -433,7 +433,7 @@ public function testWhenBeforeChecksFailTheyReturnImmediately() : void $exerciseDispatcher = new ExerciseDispatcher( $runnerManager, - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository([$check1, $check2]) ); @@ -443,7 +443,7 @@ public function testWhenBeforeChecksFailTheyReturnImmediately() : void $this->assertFalse($result->isSuccessful()); } - public function testAllEventsAreDispatched() : void + public function testAllEventsAreDispatched(): void { $input = new Input('app', ['program' => $this->file]); $exercise = new CliExerciseImpl('Some Exercise'); @@ -485,7 +485,7 @@ public function testAllEventsAreDispatched() : void $exerciseDispatcher = new ExerciseDispatcher( $runnerManager->reveal(), - new ResultAggregator, + new ResultAggregator(), $eventDispatcher->reveal(), new CheckRepository() ); @@ -493,7 +493,7 @@ public function testAllEventsAreDispatched() : void $exerciseDispatcher->verify($exercise, $input); } - public function testVerifyPostExecuteIsStillDispatchedEvenIfRunnerThrowsException() : void + public function testVerifyPostExecuteIsStillDispatchedEvenIfRunnerThrowsException(): void { $input = new Input('app', ['program' => $this->file]); $exercise = new CliExerciseImpl('Some Exercise'); @@ -518,13 +518,13 @@ public function testVerifyPostExecuteIsStillDispatchedEvenIfRunnerThrowsExceptio $runner = $this->prophesize(ExerciseRunnerInterface::class); $runner->getRequiredChecks()->willReturn([]); - $runner->verify($input)->willThrow(new RuntimeException); + $runner->verify($input)->willThrow(new RuntimeException()); $runnerManager = $this->prophesize(RunnerManager::class); $runnerManager->getRunner($exercise)->willReturn($runner->reveal()); $exerciseDispatcher = new ExerciseDispatcher( $runnerManager->reveal(), - new ResultAggregator, + new ResultAggregator(), $eventDispatcher->reveal(), new CheckRepository() ); @@ -533,7 +533,7 @@ public function testVerifyPostExecuteIsStillDispatchedEvenIfRunnerThrowsExceptio $exerciseDispatcher->verify($exercise, $input); } - public function testRun() : void + public function testRun(): void { $input = new Input('app', ['program' => $this->file]); $output = $this->prophesize(OutputInterface::class)->reveal(); @@ -547,7 +547,7 @@ public function testRun() : void $exerciseDispatcher = new ExerciseDispatcher( $runnerManager->reveal(), - new ResultAggregator, + new ResultAggregator(), new EventDispatcher(new ResultAggregator()), new CheckRepository() ); diff --git a/test/ExerciseRendererTest.php b/test/ExerciseRendererTest.php index 93933978..6375de5d 100644 --- a/test/ExerciseRendererTest.php +++ b/test/ExerciseRendererTest.php @@ -25,7 +25,7 @@ */ class ExerciseRendererTest extends TestCase { - public function testExerciseRendererSetsCurrentExerciseAndRendersExercise() : void + public function testExerciseRendererSetsCurrentExerciseAndRendersExercise(): void { $menu = $this->createMock(CliMenu::class); @@ -82,10 +82,10 @@ public function testExerciseRendererSetsCurrentExerciseAndRendersExercise() : vo $markdownRenderer = new MarkdownRenderer( new DocParser(Environment::createCommonMarkEnvironment()), - (new CliRendererFactory)->__invoke() + (new CliRendererFactory())->__invoke() ); - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $exerciseRenderer = new ExerciseRenderer( diff --git a/test/ExerciseRepositoryTest.php b/test/ExerciseRepositoryTest.php index f2712358..209c1e4c 100644 --- a/test/ExerciseRepositoryTest.php +++ b/test/ExerciseRepositoryTest.php @@ -30,7 +30,7 @@ public function testFindAll(): void $this->assertSame($exercises, $repo->findAll()); } - public function testFindByName() : void + public function testFindByName(): void { $exercises = [ new CliExerciseImpl('Exercise 1'), @@ -41,7 +41,7 @@ public function testFindByName() : void $this->assertSame($exercises[1], $repo->findByName('Exercise 2')); } - public function testFindByNameThrowsExceptionIfNotFound() : void + public function testFindByNameThrowsExceptionIfNotFound(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Exercise with name: "exercise1" does not exist'); @@ -50,7 +50,7 @@ public function testFindByNameThrowsExceptionIfNotFound() : void $repo->findByName('exercise1'); } - public function testGetAllNames() : void + public function testGetAllNames(): void { $exercises = [ new CliExerciseImpl('Exercise 1'), @@ -61,7 +61,7 @@ public function testGetAllNames() : void $this->assertSame(['Exercise 1', 'Exercise 2'], $repo->getAllNames()); } - public function testCount() : void + public function testCount(): void { $exercises = [ new CliExerciseImpl('Exercise 1'), @@ -72,7 +72,7 @@ public function testCount() : void $this->assertCount(2, $repo); } - public function testIterator() : void + public function testIterator(): void { $exercises = [ new CliExerciseImpl('Exercise 1'), @@ -83,14 +83,14 @@ public function testIterator() : void $this->assertEquals($exercises, iterator_to_array($repo)); } - public function testExceptionIsThrownWhenTryingToAddExerciseWhichDoesNotImplementCorrectInterface() : void + public function testExceptionIsThrownWhenTryingToAddExerciseWhichDoesNotImplementCorrectInterface(): void { $this->expectException(InvalidArgumentException::class); $message = '"PhpSchool\PhpWorkshopTest\Asset\CliExerciseMissingInterface" is required to implement '; $message .= '"PhpSchool\PhpWorkshop\Exercise\CliExercise", but it does not'; $this->expectExceptionMessage($message); - $exercise = new CliExerciseMissingInterface; + $exercise = new CliExerciseMissingInterface(); new ExerciseRepository([$exercise]); } } diff --git a/test/ExerciseRunner/CgiRunnerTest.php b/test/ExerciseRunner/CgiRunnerTest.php index 4985184e..1d9a7811 100644 --- a/test/ExerciseRunner/CgiRunnerTest.php +++ b/test/ExerciseRunner/CgiRunnerTest.php @@ -38,10 +38,14 @@ class CgiRunnerTest extends TestCase */ private $exercise; - public function setUp() : void + public function setUp(): void { $this->exercise = $this->createMock(CgiExerciseInterface::class); - $this->runner = new CgiRunner($this->exercise, new EventDispatcher(new ResultAggregator), new RequestRenderer); + $this->runner = new CgiRunner( + $this->exercise, + new EventDispatcher(new ResultAggregator()), + new RequestRenderer() + ); $this->exercise ->method('getType') @@ -50,7 +54,7 @@ public function setUp() : void $this->assertEquals('CGI Program Runner', $this->runner->getName()); } - public function testRequiredChecks() : void + public function testRequiredChecks(): void { $requiredChecks = [ FileExistsCheck::class, @@ -61,7 +65,7 @@ public function testRequiredChecks() : void $this->assertEquals($requiredChecks, $this->runner->getRequiredChecks()); } - public function testVerifyThrowsExceptionIfSolutionFailsExecution() : void + public function testVerifyThrowsExceptionIfSolutionFailsExecution(): void { $solution = SingleFileSolution::fromFile(__DIR__ . '/../res/cgi/solution-error.php'); $this->exercise @@ -69,7 +73,7 @@ public function testVerifyThrowsExceptionIfSolutionFailsExecution() : void ->method('getSolution') ->willReturn($solution); - $request = (new Request) + $request = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=5')); @@ -84,7 +88,7 @@ public function testVerifyThrowsExceptionIfSolutionFailsExecution() : void $this->runner->verify(new Input('app', ['program' => ''])); } - public function testVerifyReturnsSuccessIfGetSolutionOutputMatchesUserOutput() : void + public function testVerifyReturnsSuccessIfGetSolutionOutputMatchesUserOutput(): void { $solution = SingleFileSolution::fromFile(__DIR__ . '/../res/cgi/get-solution.php'); $this->exercise @@ -92,7 +96,7 @@ public function testVerifyReturnsSuccessIfGetSolutionOutputMatchesUserOutput() : ->method('getSolution') ->willReturn($solution); - $request = (new Request) + $request = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=5')); @@ -107,7 +111,7 @@ public function testVerifyReturnsSuccessIfGetSolutionOutputMatchesUserOutput() : ); } - public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutput() : void + public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutput(): void { $solution = SingleFileSolution::fromFile(__DIR__ . '/../res/cgi/post-solution.php'); $this->exercise @@ -115,7 +119,7 @@ public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutput() ->method('getSolution') ->willReturn($solution); - $request = (new Request) + $request = (new Request()) ->withMethod('POST') ->withUri(new Uri('http://some.site')) ->withHeader('Content-Type', 'application/x-www-form-urlencoded'); @@ -137,7 +141,7 @@ public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutput() $this->assertTrue($res->isSuccessful()); } - public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutputWithMultipleParams() : void + public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutputWithMultipleParams(): void { $solution = SingleFileSolution::fromFile(__DIR__ . '/../res/cgi/post-multiple-solution.php'); $this->exercise @@ -145,7 +149,7 @@ public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutputWit ->method('getSolution') ->willReturn($solution); - $request = (new Request) + $request = (new Request()) ->withMethod('POST') ->withUri(new Uri('http://some.site')) ->withHeader('Content-Type', 'application/x-www-form-urlencoded'); @@ -164,7 +168,7 @@ public function testVerifyReturnsSuccessIfPostSolutionOutputMatchesUserOutputWit $this->assertInstanceOf(CgiResult::class, $result); } - public function testVerifyReturnsFailureIfUserSolutionFailsToExecute() : void + public function testVerifyReturnsFailureIfUserSolutionFailsToExecute(): void { $solution = SingleFileSolution::fromFile(__DIR__ . '/../res/cgi/get-solution.php'); $this->exercise @@ -172,7 +176,7 @@ public function testVerifyReturnsFailureIfUserSolutionFailsToExecute() : void ->method('getSolution') ->willReturn($solution); - $request = (new Request) + $request = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=5')); @@ -196,7 +200,7 @@ public function testVerifyReturnsFailureIfUserSolutionFailsToExecute() : void $this->assertMatchesRegularExpression($failureMsg, $result->getReason()); } - public function testVerifyReturnsFailureIfSolutionOutputDoesNotMatchUserOutput() : void + public function testVerifyReturnsFailureIfSolutionOutputDoesNotMatchUserOutput(): void { $solution = SingleFileSolution::fromFile(__DIR__ . '/../res/cgi/get-solution.php'); $this->exercise @@ -204,7 +208,7 @@ public function testVerifyReturnsFailureIfSolutionOutputDoesNotMatchUserOutput() ->method('getSolution') ->willReturn($solution); - $request = (new Request) + $request = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=5')); @@ -228,7 +232,7 @@ public function testVerifyReturnsFailureIfSolutionOutputDoesNotMatchUserOutput() $this->assertEquals(['Content-type' => 'text/html; charset=UTF-8'], $result->getActualHeaders()); } - public function testVerifyReturnsFailureIfSolutionOutputHeadersDoesNotMatchUserOutputHeaders() : void + public function testVerifyReturnsFailureIfSolutionOutputHeadersDoesNotMatchUserOutputHeaders(): void { $solution = SingleFileSolution::fromFile(__DIR__ . '/../res/cgi/get-solution-header.php'); $this->exercise @@ -236,7 +240,7 @@ public function testVerifyReturnsFailureIfSolutionOutputHeadersDoesNotMatchUserO ->method('getSolution') ->willReturn($solution); - $request = (new Request) + $request = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=5')); @@ -272,16 +276,16 @@ public function testVerifyReturnsFailureIfSolutionOutputHeadersDoesNotMatchUserO ); } - public function testRunPassesOutputAndReturnsSuccessIfAllRequestsAreSuccessful() : void + public function testRunPassesOutputAndReturnsSuccessIfAllRequestsAreSuccessful(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); - $request1 = (new Request) + $request1 = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=5')); - $request2 = (new Request) + $request2 = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=6')); @@ -321,12 +325,12 @@ public function testRunPassesOutputAndReturnsSuccessIfAllRequestsAreSuccessful() $this->assertTrue($success); } - public function testRunPassesOutputAndReturnsFailureIfARequestFails() : void + public function testRunPassesOutputAndReturnsFailureIfARequestFails(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); - $request1 = (new Request) + $request1 = (new Request()) ->withMethod('GET') ->withUri(new Uri('http://some.site?number=5')); diff --git a/test/ExerciseRunner/CliRunnerTest.php b/test/ExerciseRunner/CliRunnerTest.php index ca35d4f9..3244d3d8 100644 --- a/test/ExerciseRunner/CliRunnerTest.php +++ b/test/ExerciseRunner/CliRunnerTest.php @@ -41,10 +41,10 @@ class CliRunnerTest extends TestCase */ private $eventDispatcher; - public function setUp() : void + public function setUp(): void { $this->exercise = $this->createMock(CliExerciseInterface::class); - $this->eventDispatcher = new EventDispatcher(new ResultAggregator); + $this->eventDispatcher = new EventDispatcher(new ResultAggregator()); $this->runner = new CliRunner($this->exercise, $this->eventDispatcher); $this->exercise @@ -54,7 +54,7 @@ public function setUp() : void $this->assertEquals('CLI Program Runner', $this->runner->getName()); } - public function testRequiredChecks() : void + public function testRequiredChecks(): void { $requiredChecks = [ FileExistsCheck::class, @@ -65,7 +65,7 @@ public function testRequiredChecks() : void $this->assertEquals($requiredChecks, $this->runner->getRequiredChecks()); } - public function testVerifyThrowsExceptionIfSolutionFailsExecution() : void + public function testVerifyThrowsExceptionIfSolutionFailsExecution(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/cli/solution-error.php')); $this->exercise @@ -85,7 +85,7 @@ public function testVerifyThrowsExceptionIfSolutionFailsExecution() : void $this->runner->verify(new Input('app', ['program' => ''])); } - public function testVerifyReturnsSuccessIfSolutionOutputMatchesUserOutput() : void + public function testVerifyReturnsSuccessIfSolutionOutputMatchesUserOutput(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/cli/solution.php')); $this->exercise @@ -106,7 +106,7 @@ public function testVerifyReturnsSuccessIfSolutionOutputMatchesUserOutput() : vo $this->assertTrue($res->isSuccessful()); } - public function testSuccessWithSingleSetOfArgsForBC() : void + public function testSuccessWithSingleSetOfArgsForBC(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/cli/solution.php')); $this->exercise @@ -127,7 +127,7 @@ public function testSuccessWithSingleSetOfArgsForBC() : void $this->assertTrue($res->isSuccessful()); } - public function testVerifyReturnsFailureIfUserSolutionFailsToExecute() : void + public function testVerifyReturnsFailureIfUserSolutionFailsToExecute(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/cli/solution.php')); $this->exercise @@ -153,7 +153,7 @@ public function testVerifyReturnsFailureIfUserSolutionFailsToExecute() : void $this->assertMatchesRegularExpression($failureMsg, $result->getReason()); } - public function testVerifyReturnsFailureIfSolutionOutputDoesNotMatchUserOutput() : void + public function testVerifyReturnsFailureIfSolutionOutputDoesNotMatchUserOutput(): void { $solution = SingleFileSolution::fromFile(realpath(__DIR__ . '/../res/cli/solution.php')); $this->exercise @@ -178,9 +178,9 @@ public function testVerifyReturnsFailureIfSolutionOutputDoesNotMatchUserOutput() $this->assertEquals('10', $result->getActualOutput()); } - public function testRunPassesOutputAndReturnsSuccessIfScriptIsSuccessful() : void + public function testRunPassesOutputAndReturnsSuccessIfScriptIsSuccessful(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); @@ -206,9 +206,9 @@ public function testRunPassesOutputAndReturnsSuccessIfScriptIsSuccessful() : voi $this->assertTrue($success); } - public function testRunPassesOutputAndReturnsFailureIfScriptFails() : void + public function testRunPassesOutputAndReturnsFailureIfScriptFails(): void { - $output = new StdOutput(new Color, $this->createMock(Terminal::class)); + $output = new StdOutput(new Color(), $this->createMock(Terminal::class)); $this->exercise ->expects($this->once()) @@ -223,7 +223,7 @@ public function testRunPassesOutputAndReturnsFailureIfScriptFails() : void $this->assertFalse($success); } - public function testsArgsAppendedByEventsArePassedToResults() : void + public function testsArgsAppendedByEventsArePassedToResults(): void { $this->eventDispatcher->listen( ['cli.verify.student-execute.pre', 'cli.verify.reference-execute.pre'], diff --git a/test/ExerciseRunner/CustomVerifyingRunnerTest.php b/test/ExerciseRunner/CustomVerifyingRunnerTest.php index ce47077b..d93c31e3 100644 --- a/test/ExerciseRunner/CustomVerifyingRunnerTest.php +++ b/test/ExerciseRunner/CustomVerifyingRunnerTest.php @@ -25,22 +25,22 @@ class CustomVerifyingRunnerTest extends TestCase */ private $exercise; - public function setUp() : void + public function setUp(): void { - $this->exercise = new CustomVerifyingExerciseImpl; + $this->exercise = new CustomVerifyingExerciseImpl(); $this->runner = new CustomVerifyingRunner($this->exercise); $this->assertEquals('Custom Verifying Runner', $this->runner->getName()); } - public function testRequiredChecks() : void + public function testRequiredChecks(): void { $this->assertEquals([], $this->runner->getRequiredChecks()); } - public function testRunOutputsErrorMessage() : void + public function testRunOutputsErrorMessage(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); @@ -52,7 +52,7 @@ public function testRunOutputsErrorMessage() : void $this->runner->run(new Input('app'), $output); } - public function testVerifyProxiesToExercise() : void + public function testVerifyProxiesToExercise(): void { self::assertEquals($this->exercise->verify(), $this->runner->verify(new Input('app'))); } diff --git a/test/ExerciseRunner/Factory/CgiRunnerFactoryTest.php b/test/ExerciseRunner/Factory/CgiRunnerFactoryTest.php index fe9c156c..001643b7 100644 --- a/test/ExerciseRunner/Factory/CgiRunnerFactoryTest.php +++ b/test/ExerciseRunner/Factory/CgiRunnerFactoryTest.php @@ -27,10 +27,10 @@ class CgiRunnerFactoryTest extends TestCase public function setUp(): void { $this->eventDispatcher = $this->createMock(EventDispatcher::class); - $this->factory = new CgiRunnerFactory($this->eventDispatcher, new RequestRenderer); + $this->factory = new CgiRunnerFactory($this->eventDispatcher, new RequestRenderer()); } - public function testSupports() : void + public function testSupports(): void { $exercise1 = $this->prophesize(ExerciseInterface::class); $exercise2 = $this->prophesize(ExerciseInterface::class); @@ -42,7 +42,7 @@ public function testSupports() : void $this->assertFalse($this->factory->supports($exercise2->reveal())); } - public function testConfigureInputAddsProgramArgument() : void + public function testConfigureInputAddsProgramArgument(): void { $command = new CommandDefinition('my-command', [], 'var_dump'); @@ -53,9 +53,9 @@ public function testConfigureInputAddsProgramArgument() : void $this->assertTrue($command->getRequiredArgs()[0]->isRequired()); } - public function testCreateReturnsRunner() : void + public function testCreateReturnsRunner(): void { - $exercise = new CgiExerciseImpl; + $exercise = new CgiExerciseImpl(); $this->assertInstanceOf(CgiRunner::class, $this->factory->create($exercise)); } } diff --git a/test/ExerciseRunner/Factory/CliRunnerFactoryTest.php b/test/ExerciseRunner/Factory/CliRunnerFactoryTest.php index 1455d164..56206ebf 100644 --- a/test/ExerciseRunner/Factory/CliRunnerFactoryTest.php +++ b/test/ExerciseRunner/Factory/CliRunnerFactoryTest.php @@ -29,7 +29,7 @@ public function setUp(): void $this->factory = new CliRunnerFactory($this->eventDispatcher); } - public function testSupports() : void + public function testSupports(): void { $exercise1 = $this->prophesize(ExerciseInterface::class); $exercise2 = $this->prophesize(ExerciseInterface::class); @@ -41,7 +41,7 @@ public function testSupports() : void $this->assertFalse($this->factory->supports($exercise2->reveal())); } - public function testConfigureInputAddsProgramArgument() : void + public function testConfigureInputAddsProgramArgument(): void { $command = new CommandDefinition('my-command', [], 'var_dump'); @@ -52,9 +52,9 @@ public function testConfigureInputAddsProgramArgument() : void $this->assertTrue($command->getRequiredArgs()[0]->isRequired()); } - public function testCreateReturnsRunner() : void + public function testCreateReturnsRunner(): void { - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $this->assertInstanceOf(CliRunner::class, $this->factory->create($exercise)); } } diff --git a/test/ExerciseRunner/Factory/CustomVerifyingRunnerFactoryTest.php b/test/ExerciseRunner/Factory/CustomVerifyingRunnerFactoryTest.php index 7cc935c4..6a4e1a0b 100644 --- a/test/ExerciseRunner/Factory/CustomVerifyingRunnerFactoryTest.php +++ b/test/ExerciseRunner/Factory/CustomVerifyingRunnerFactoryTest.php @@ -19,10 +19,10 @@ class CustomVerifyingRunnerFactoryTest extends TestCase public function setUp(): void { - $this->factory = new CustomVerifyingRunnerFactory; + $this->factory = new CustomVerifyingRunnerFactory(); } - public function testSupports() : void + public function testSupports(): void { $exercise1 = $this->prophesize(ExerciseInterface::class); $exercise2 = $this->prophesize(ExerciseInterface::class); @@ -37,7 +37,7 @@ public function testSupports() : void $this->assertTrue($this->factory->supports($exercise3->reveal())); } - public function testConfigureInputAddsNoArgument() : void + public function testConfigureInputAddsNoArgument(): void { $command = new CommandDefinition('my-command', [], 'var_dump'); @@ -45,9 +45,9 @@ public function testConfigureInputAddsNoArgument() : void $this->assertCount(0, $command->getRequiredArgs()); } - public function testCreateReturnsRunner() : void + public function testCreateReturnsRunner(): void { - $exercise = new CustomVerifyingExerciseImpl; + $exercise = new CustomVerifyingExerciseImpl(); $this->assertInstanceOf(CustomVerifyingRunner::class, $this->factory->create($exercise)); } } diff --git a/test/ExerciseRunner/RunnerManagerTest.php b/test/ExerciseRunner/RunnerManagerTest.php index a8fa3589..e5cfc87a 100644 --- a/test/ExerciseRunner/RunnerManagerTest.php +++ b/test/ExerciseRunner/RunnerManagerTest.php @@ -14,10 +14,10 @@ */ class RunnerManagerTest extends TestCase { - public function testConfigureInputCallsCorrectFactory() : void + public function testConfigureInputCallsCorrectFactory(): void { - $exercise = new CliExerciseImpl; - $manager = new RunnerManager; + $exercise = new CliExerciseImpl(); + $manager = new RunnerManager(); $command = new CommandDefinition('my-command', [], 'var_dump'); $factory1 = $this->prophesize(ExerciseRunnerFactoryInterface::class); @@ -33,10 +33,10 @@ public function testConfigureInputCallsCorrectFactory() : void $manager->configureInput($exercise, $command); } - public function testGetRunnerCallsCorrectFactory() : void + public function testGetRunnerCallsCorrectFactory(): void { - $exercise = new CliExerciseImpl; - $manager = new RunnerManager; + $exercise = new CliExerciseImpl(); + $manager = new RunnerManager(); $factory1 = $this->prophesize(ExerciseRunnerFactoryInterface::class); $factory1->supports($exercise)->willReturn(false); @@ -51,10 +51,10 @@ public function testGetRunnerCallsCorrectFactory() : void $manager->getRunner($exercise); } - public function testExceptionIsThrownWhenConfiguringInputIfNoFactorySupportsExercise() : void + public function testExceptionIsThrownWhenConfiguringInputIfNoFactorySupportsExercise(): void { - $exercise = new CliExerciseImpl; - $manager = new RunnerManager; + $exercise = new CliExerciseImpl(); + $manager = new RunnerManager(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Exercise Type: "CLI" not supported'); @@ -62,10 +62,10 @@ public function testExceptionIsThrownWhenConfiguringInputIfNoFactorySupportsExer $manager->configureInput($exercise, new CommandDefinition('my-command', [], 'var_dump')); } - public function testExceptionIsThrownWhenGettingRunnerIfNoFactorySupportsExercise() : void + public function testExceptionIsThrownWhenGettingRunnerIfNoFactorySupportsExercise(): void { - $exercise = new CliExerciseImpl; - $manager = new RunnerManager; + $exercise = new CliExerciseImpl(); + $manager = new RunnerManager(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Exercise Type: "CLI" not supported'); diff --git a/test/Factory/CliRendererFactoryTest.php b/test/Factory/CliRendererFactoryTest.php index f9d7f608..c235941b 100644 --- a/test/Factory/CliRendererFactoryTest.php +++ b/test/Factory/CliRendererFactoryTest.php @@ -15,7 +15,7 @@ */ class CliRendererFactoryTest extends TestCase { - public function testFactoryReturnsInstance() : void + public function testFactoryReturnsInstance(): void { $terminal = $this->createMock(Terminal::class); $terminal @@ -25,7 +25,7 @@ public function testFactoryReturnsInstance() : void $services = [ Terminal::class => $terminal, - Color::class => new Color, + Color::class => new Color(), ]; $c = $this->createMock(ContainerInterface::class); diff --git a/test/Factory/EventDispatcherFactoryTest.php b/test/Factory/EventDispatcherFactoryTest.php index d261b501..20535afa 100644 --- a/test/Factory/EventDispatcherFactoryTest.php +++ b/test/Factory/EventDispatcherFactoryTest.php @@ -4,7 +4,6 @@ use DI\ContainerBuilder; use PhpSchool\PhpWorkshop\Event\Event; -use function PhpSchool\PhpWorkshop\Event\containerListener; use Interop\Container\ContainerInterface; use PhpSchool\PhpWorkshop\Event\EventDispatcher; use PhpSchool\PhpWorkshop\Exception\InvalidArgumentException; @@ -12,6 +11,8 @@ use PhpSchool\PhpWorkshop\ResultAggregator; use PHPUnit\Framework\TestCase; +use function PhpSchool\PhpWorkshop\Event\containerListener; + /** * Class EventDispatcherFactoryTest * @package PhpSchool\PhpWorkshopTest\Event @@ -19,82 +20,82 @@ */ class EventDispatcherFactoryTest extends TestCase { - public function testCreateWithNoConfig() : void + public function testCreateWithNoConfig(): void { $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(false); - $dispatcher = (new EventDispatcherFactory)->__invoke($c->reveal()); + $dispatcher = (new EventDispatcherFactory())->__invoke($c->reveal()); $this->assertInstanceOf(EventDispatcher::class, $dispatcher); $this->assertSame([], $dispatcher->getListeners()); } - public function testExceptionIsThrownIfEventListenerGroupsNotArray() : void + public function testExceptionIsThrownIfEventListenerGroupsNotArray(): void { $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); - $c->get('eventListeners')->willReturn(new \stdClass); + $c->get('eventListeners')->willReturn(new \stdClass()); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Expected: "array" Received: "stdClass"'); - (new EventDispatcherFactory)->__invoke($c->reveal()); + (new EventDispatcherFactory())->__invoke($c->reveal()); } - public function testExceptionIsThrownIfEventsNotArray() : void + public function testExceptionIsThrownIfEventsNotArray(): void { $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); - $c->get('eventListeners')->willReturn(['my-group' => new \stdClass]); + $c->get('eventListeners')->willReturn(['my-group' => new \stdClass()]); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Expected: "array" Received: "stdClass"'); - (new EventDispatcherFactory)->__invoke($c->reveal()); + (new EventDispatcherFactory())->__invoke($c->reveal()); } - public function testExceptionIsThrownIfEventListenersNotArray() : void + public function testExceptionIsThrownIfEventListenersNotArray(): void { $eventConfig = [ 'my-group' => [ - 'someEvent' => new \stdClass + 'someEvent' => new \stdClass() ] ]; $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); $c->get('eventListeners')->willReturn($eventConfig); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Expected: "array" Received: "stdClass"'); - (new EventDispatcherFactory)->__invoke($c->reveal()); + (new EventDispatcherFactory())->__invoke($c->reveal()); } - public function testExceptionIsThrownIfListenerNotCallable() : void + public function testExceptionIsThrownIfListenerNotCallable(): void { $eventConfig = [ 'my-group' => [ - 'someEvent' => [new \stdClass] + 'someEvent' => [new \stdClass()] ] ]; $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); $c->get('eventListeners')->willReturn($eventConfig); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Listener must be a callable or a container entry for a callable service.'); - (new EventDispatcherFactory)->__invoke($c->reveal()); + (new EventDispatcherFactory())->__invoke($c->reveal()); } - public function testExceptionIsThrownIfEventsListenerContainerEntryNotExist() : void + public function testExceptionIsThrownIfEventsListenerContainerEntryNotExist(): void { $eventConfig = [ 'my-group' => [ @@ -103,7 +104,7 @@ public function testExceptionIsThrownIfEventsListenerContainerEntryNotExist() : ]; $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); $c->get('eventListeners')->willReturn($eventConfig); @@ -112,10 +113,10 @@ public function testExceptionIsThrownIfEventsListenerContainerEntryNotExist() : $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Container has no entry named: "nonExistingContainerEntry"'); - (new EventDispatcherFactory)->__invoke($c->reveal()); + (new EventDispatcherFactory())->__invoke($c->reveal()); } - public function testConfigEventListenersWithAnonymousFunction() : void + public function testConfigEventListenersWithAnonymousFunction(): void { $callback = function () { }; @@ -127,11 +128,11 @@ public function testConfigEventListenersWithAnonymousFunction() : void ]; $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); $c->get('eventListeners')->willReturn($eventConfig); - $dispatcher = (new EventDispatcherFactory)->__invoke($c->reveal()); + $dispatcher = (new EventDispatcherFactory())->__invoke($c->reveal()); $this->assertInstanceOf(EventDispatcher::class, $dispatcher); $this->assertSame( [ @@ -143,7 +144,7 @@ public function testConfigEventListenersWithAnonymousFunction() : void ); } - public function testListenerFromContainerIsNotFetchedDuringAttaching() : void + public function testListenerFromContainerIsNotFetchedDuringAttaching(): void { $eventConfig = [ 'my-group' => [ @@ -153,20 +154,20 @@ public function testListenerFromContainerIsNotFetchedDuringAttaching() : void $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); $c->get('eventListeners')->willReturn($eventConfig); $c->has('containerEntry')->willReturn(true); - $dispatcher = (new EventDispatcherFactory)->__invoke($c->reveal()); + $dispatcher = (new EventDispatcherFactory())->__invoke($c->reveal()); $this->assertInstanceOf(EventDispatcher::class, $dispatcher); $this->assertArrayHasKey('someEvent', $dispatcher->getListeners()); $c->get('containerEntry')->shouldNotHaveBeenCalled(); } - public function testListenerFromContainerIsFetchedWhenEventDispatched() : void + public function testListenerFromContainerIsFetchedWhenEventDispatched(): void { $eventConfig = [ 'my-group' => [ @@ -176,21 +177,21 @@ public function testListenerFromContainerIsFetchedWhenEventDispatched() : void $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); $c->get('eventListeners')->willReturn($eventConfig); $c->has('containerEntry')->willReturn(true); $c->get('containerEntry')->willReturn(function () { }); - $dispatcher = (new EventDispatcherFactory)->__invoke($c->reveal()); + $dispatcher = (new EventDispatcherFactory())->__invoke($c->reveal()); $this->assertInstanceOf(EventDispatcher::class, $dispatcher); $this->assertArrayHasKey('someEvent', $dispatcher->getListeners()); $dispatcher->dispatch(new Event('someEvent')); } - public function testExceptionIsThrownIfMethodDoesNotExistOnContainerEntry() : void + public function testExceptionIsThrownIfMethodDoesNotExistOnContainerEntry(): void { $eventConfig = [ 'my-group' => [ @@ -200,29 +201,29 @@ public function testExceptionIsThrownIfMethodDoesNotExistOnContainerEntry() : vo $c = $this->prophesize(ContainerInterface::class); - $c->get(ResultAggregator::class)->willReturn(new ResultAggregator); + $c->get(ResultAggregator::class)->willReturn(new ResultAggregator()); $c->has('eventListeners')->willReturn(true); $c->get('eventListeners')->willReturn($eventConfig); $c->has('containerEntry')->willReturn(true); - $c->get('containerEntry')->willReturn(new \stdClass); + $c->get('containerEntry')->willReturn(new \stdClass()); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Method "notHere" does not exist on "stdClass"'); - $dispatcher = (new EventDispatcherFactory)->__invoke($c->reveal()); + $dispatcher = (new EventDispatcherFactory())->__invoke($c->reveal()); $this->assertInstanceOf(EventDispatcher::class, $dispatcher); $dispatcher->dispatch(new Event('someEvent')); } - public function testDefaultListenersAreRegisteredFromConfig() : void + public function testDefaultListenersAreRegisteredFromConfig(): void { - $containerBuilder = new ContainerBuilder; + $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions(__DIR__ . '/../../app/config.php'); $container = $containerBuilder->build(); - $dispatcher = (new EventDispatcherFactory)->__invoke($container); + $dispatcher = (new EventDispatcherFactory())->__invoke($container); $listeners = $dispatcher->getListeners(); diff --git a/test/Factory/MenuFactoryTest.php b/test/Factory/MenuFactoryTest.php index 01d7bf9b..08da135e 100644 --- a/test/Factory/MenuFactoryTest.php +++ b/test/Factory/MenuFactoryTest.php @@ -25,14 +25,14 @@ */ class MenuFactoryTest extends TestCase { - public function testFactoryReturnsInstance() : void + public function testFactoryReturnsInstance(): void { $container = $this->createMock(ContainerInterface::class); $userStateSerializer = $this->createMock(UserStateSerializer::class); $userStateSerializer ->expects($this->once()) ->method('deSerialize') - ->willReturn(new UserState); + ->willReturn(new UserState()); $exerciseRepository = $this->createMock(ExerciseRepository::class); $exercise = $this->createMock(ExerciseInterface::class); @@ -72,7 +72,7 @@ public function testFactoryReturnsInstance() : void }); - $factory = new MenuFactory; + $factory = new MenuFactory(); $this->assertInstanceOf(CliMenu::class, $factory($container)); } } diff --git a/test/Factory/ResultRendererFactoryTest.php b/test/Factory/ResultRendererFactoryTest.php index 9a6ef4a0..349e6591 100644 --- a/test/Factory/ResultRendererFactoryTest.php +++ b/test/Factory/ResultRendererFactoryTest.php @@ -16,7 +16,7 @@ */ class ResultRendererFactoryTest extends TestCase { - public function testRegisterRendererRequiresResultInterface() : void + public function testRegisterRendererRequiresResultInterface(): void { $this->expectException(InvalidArgumentException::class); @@ -27,7 +27,7 @@ public function testRegisterRendererRequiresResultInterface() : void $factory->registerRenderer($resultClass, $rendererClass); } - public function testRegisterRendererRequiresResultRendererInterface() : void + public function testRegisterRendererRequiresResultRendererInterface(): void { $this->expectException(InvalidArgumentException::class); @@ -38,7 +38,7 @@ public function testRegisterRendererRequiresResultRendererInterface() : void $factory->registerRenderer($resultClass, $rendererClass); } - public function testRegisterRendererRequiresResultClassToBeString() : void + public function testRegisterRendererRequiresResultClassToBeString(): void { $this->expectException(InvalidArgumentException::class); @@ -49,7 +49,7 @@ public function testRegisterRendererRequiresResultClassToBeString() : void $factory->registerRenderer($resultClass, $rendererClass); } - public function testRegisterRendererRequiresRendererClassToBeString() : void + public function testRegisterRendererRequiresRendererClassToBeString(): void { $this->expectException(InvalidArgumentException::class); @@ -60,7 +60,7 @@ public function testRegisterRendererRequiresRendererClassToBeString() : void $factory->registerRenderer($resultClass, $rendererClass); } - public function testCreateRequiresMappingToClassName() : void + public function testCreateRequiresMappingToClassName(): void { $this->expectException(RuntimeException::class); @@ -70,7 +70,7 @@ public function testCreateRequiresMappingToClassName() : void $factory->create($resultClass); } - public function testCreateReturnsMappedRendererInterface() : void + public function testCreateReturnsMappedRendererInterface(): void { $resultClass = $this->createMock(ResultInterface::class); $resultClassName = get_class($resultClass); @@ -83,14 +83,14 @@ public function testCreateReturnsMappedRendererInterface() : void $this->assertInstanceOf($rendererClassName, $returnedRenderer); } - public function testExceptionIsThrownIfFactoryReturnsInCorrectRenderer() : void + public function testExceptionIsThrownIfFactoryReturnsInCorrectRenderer(): void { $resultClass = $this->createMock(ResultInterface::class); $resultClassName = get_class($resultClass); $rendererClassName = get_class($this->createMock(ResultRendererInterface::class)); $factory = new ResultRendererFactory(); $factory->registerRenderer($resultClassName, $rendererClassName, function () { - return new \stdClass; + return new \stdClass(); }); $this->expectException(RuntimeException::class); diff --git a/test/FunctionsTest.php b/test/FunctionsTest.php index a9ded71d..1835e6fd 100644 --- a/test/FunctionsTest.php +++ b/test/FunctionsTest.php @@ -12,12 +12,12 @@ class FunctionsTest extends TestCase /** * @dataProvider mbStrPadProvider */ - public function testMbStrPad(string $string, int $pad, string $expected) : void + public function testMbStrPad(string $string, int $pad, string $expected): void { self::assertSame(mb_str_pad($string, $pad), $expected); } - public function mbStrPadProvider() : array + public function mbStrPadProvider(): array { return [ ['hello', 10, 'hello '], @@ -28,12 +28,12 @@ public function mbStrPadProvider() : array /** * @dataProvider camelCaseToKebabCaseProvider */ - public function testCamelCaseToKebabCase(string $string, string $expected) : void + public function testCamelCaseToKebabCase(string $string, string $expected): void { self::assertSame(camel_case_to_kebab_case($string), $expected); } - public function camelCaseToKebabCaseProvider() : array + public function camelCaseToKebabCaseProvider(): array { return [ ['camelCase', 'camel-case'], diff --git a/test/Listener/CheckExerciseAssignedListenerTest.php b/test/Listener/CheckExerciseAssignedListenerTest.php index 2540e75c..37d33717 100644 --- a/test/Listener/CheckExerciseAssignedListenerTest.php +++ b/test/Listener/CheckExerciseAssignedListenerTest.php @@ -17,9 +17,9 @@ class CheckExerciseAssignedListenerTest extends TestCase /** * @dataProvider commandsThatRequireAssignedExercise */ - public function testExceptionIsThrownIfNoExerciseAssigned(CommandDefinition $command) : void + public function testExceptionIsThrownIfNoExerciseAssigned(CommandDefinition $command): void { - $state = new UserState; + $state = new UserState(); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('No active exercise. Select one from the menu'); @@ -31,7 +31,7 @@ public function testExceptionIsThrownIfNoExerciseAssigned(CommandDefinition $com /** * @dataProvider commandsThatRequireAssignedExercise */ - public function testExceptionIsNotThrownIfExerciseAssigned(CommandDefinition $command) : void + public function testExceptionIsNotThrownIfExerciseAssigned(CommandDefinition $command): void { $state = new UserState(['exercise1'], 'exercise1'); $listener = new CheckExerciseAssignedListener($state); @@ -40,7 +40,7 @@ public function testExceptionIsNotThrownIfExerciseAssigned(CommandDefinition $co $this->assertTrue($state->isAssignedExercise()); } - public function commandsThatRequireAssignedExercise() : array + public function commandsThatRequireAssignedExercise(): array { return [ [$this->command('verify')], @@ -52,7 +52,7 @@ public function commandsThatRequireAssignedExercise() : array /** * @dataProvider commandsThatDoNotRequireAssignedExercise */ - public function testExceptionIsNotThrownIfCommandDoesNotRequireAssignedExercise(CommandDefinition $command) : void + public function testExceptionIsNotThrownIfCommandDoesNotRequireAssignedExercise(CommandDefinition $command): void { $state = new UserState(['exercise1'], 'exercise1'); $listener = new CheckExerciseAssignedListener($state); @@ -61,7 +61,7 @@ public function testExceptionIsNotThrownIfCommandDoesNotRequireAssignedExercise( $this->assertTrue($state->isAssignedExercise()); } - public function commandsThatDoNotRequireAssignedExercise() : array + public function commandsThatDoNotRequireAssignedExercise(): array { return [ [$this->command('help')], @@ -73,7 +73,7 @@ public function commandsThatDoNotRequireAssignedExercise() : array /** * @return MockObject|CommandDefinition */ - private function command(string $commandName) : MockObject + private function command(string $commandName): MockObject { $command = $this->createMock(CommandDefinition::class); $command diff --git a/test/Listener/CodePatchListenerTest.php b/test/Listener/CodePatchListenerTest.php index e049b301..88d755fb 100644 --- a/test/Listener/CodePatchListenerTest.php +++ b/test/Listener/CodePatchListenerTest.php @@ -33,9 +33,9 @@ class CodePatchListenerTest extends TestCase */ private $codePatcher; - public function setUp() : void + public function setUp(): void { - $this->filesystem = new Filesystem; + $this->filesystem = new Filesystem(); $this->codePatcher = $this->createMock(CodePatcher::class); $this->file = sprintf('%s/%s/submission.php', str_replace('\\', '/', sys_get_temp_dir()), $this->getName()); @@ -43,7 +43,7 @@ public function setUp() : void touch($this->file); } - public function testRevertThrowsExceptionIfPatchNotPreviouslyCalled() : void + public function testRevertThrowsExceptionIfPatchNotPreviouslyCalled(): void { $input = new Input('app', ['program' => $this->file]); $exercise = $this->createMock(ExerciseInterface::class); @@ -56,7 +56,7 @@ public function testRevertThrowsExceptionIfPatchNotPreviouslyCalled() : void $listener->revert($event); } - public function testPatchUpdatesCode() : void + public function testPatchUpdatesCode(): void { file_put_contents($this->file, 'ORIGINAL CONTENT'); @@ -76,7 +76,7 @@ public function testPatchUpdatesCode() : void $this->assertStringEqualsFile($this->file, 'MODIFIED CONTENT'); } - public function testRevertAfterPatch() : void + public function testRevertAfterPatch(): void { file_put_contents($this->file, 'ORIGINAL CONTENT'); @@ -97,7 +97,7 @@ public function testRevertAfterPatch() : void $this->assertStringEqualsFile($this->file, 'ORIGINAL CONTENT'); } - public function tearDown() : void + public function tearDown(): void { $this->filesystem->remove(dirname($this->file)); } diff --git a/test/Listener/ConfigureCommandListenerTest.php b/test/Listener/ConfigureCommandListenerTest.php index e262bfb6..ec3188bc 100644 --- a/test/Listener/ConfigureCommandListenerTest.php +++ b/test/Listener/ConfigureCommandListenerTest.php @@ -19,7 +19,7 @@ class ConfigureCommandListenerTest extends TestCase /** * @dataProvider configurableCommands */ - public function testInputIsConfiguredForCorrectCommands(string $commandName) : void + public function testInputIsConfiguredForCorrectCommands(string $commandName): void { $command = new CommandDefinition($commandName, [], function () { }); @@ -35,7 +35,7 @@ public function testInputIsConfiguredForCorrectCommands(string $commandName) : v (new ConfigureCommandListener($state, $repo, $runnerManager->reveal()))->__invoke($event); } - public function configurableCommands() : array + public function configurableCommands(): array { return [ ['verify'], @@ -46,7 +46,7 @@ public function configurableCommands() : array /** * @dataProvider nonConfigurableCommands */ - public function testInputIsNotConfiguredForCorrectCommands(string $commandName) : void + public function testInputIsNotConfiguredForCorrectCommands(string $commandName): void { $command = new CommandDefinition($commandName, [], function () { }); @@ -63,7 +63,7 @@ public function testInputIsNotConfiguredForCorrectCommands(string $commandName) $runnerManager->configureInput($exercise, $command)->shouldNotHaveBeenCalled(); } - public function nonConfigurableCommands() : array + public function nonConfigurableCommands(): array { return [ ['print'], diff --git a/test/Listener/PrepareSolutionListenerTest.php b/test/Listener/PrepareSolutionListenerTest.php index 9cf23e16..54b1e11a 100644 --- a/test/Listener/PrepareSolutionListenerTest.php +++ b/test/Listener/PrepareSolutionListenerTest.php @@ -36,17 +36,17 @@ class PrepareSolutionListenerTest extends TestCase */ private $filesystem; - public function setUp() : void + public function setUp(): void { - $this->filesystem = new Filesystem; - $this->listener = new PrepareSolutionListener; + $this->filesystem = new Filesystem(); + $this->listener = new PrepareSolutionListener(); $this->file = sprintf('%s/%s/submission.php', str_replace('\\', '/', sys_get_temp_dir()), $this->getName()); mkdir(dirname($this->file), 0775, true); touch($this->file); } - public function testIfSolutionRequiresComposerButComposerCannotBeLocatedExceptionIsThrown() : void + public function testIfSolutionRequiresComposerButComposerCannotBeLocatedExceptionIsThrown(): void { $refProp = new ReflectionProperty(PrepareSolutionListener::class, 'composerLocations'); $refProp->setAccessible(true); @@ -69,7 +69,7 @@ public function testIfSolutionRequiresComposerButComposerCannotBeLocatedExceptio $this->listener->__invoke($event); } - public function testIfSolutionRequiresComposerButVendorDirExistsNothingIsDone() : void + public function testIfSolutionRequiresComposerButVendorDirExistsNothingIsDone(): void { mkdir(sprintf('%s/vendor', dirname($this->file))); $this->assertFileExists(sprintf('%s/vendor', dirname($this->file))); @@ -97,7 +97,7 @@ public function testIfSolutionRequiresComposerButVendorDirExistsNothingIsDone() $this->assertFileDoesNotExist(sprintf('%s/composer.lock', dirname($this->file))); } - public function testIfSolutionRequiresComposerComposerInstallIsExecuted() : void + public function testIfSolutionRequiresComposerComposerInstallIsExecuted(): void { $this->assertFileDoesNotExist(sprintf('%s/vendor', dirname($this->file))); file_put_contents(sprintf('%s/composer.json', dirname($this->file)), json_encode([ @@ -127,7 +127,7 @@ public function testIfSolutionRequiresComposerComposerInstallIsExecuted() : void $this->assertFileExists(sprintf('%s/vendor', dirname($this->file))); } - public function tearDown() : void + public function tearDown(): void { $this->filesystem->remove(dirname($this->file)); } diff --git a/test/Listener/RealPathListenerTest.php b/test/Listener/RealPathListenerTest.php index 54740ecc..18334bbd 100644 --- a/test/Listener/RealPathListenerTest.php +++ b/test/Listener/RealPathListenerTest.php @@ -14,7 +14,7 @@ */ class RealPathListenerTest extends TestCase { - public function testInputArgumentIsReplacesWithAbsolutePathIfFileExists() : void + public function testInputArgumentIsReplacesWithAbsolutePathIfFileExists(): void { $current = getcwd(); @@ -23,9 +23,9 @@ public function testInputArgumentIsReplacesWithAbsolutePathIfFileExists() : void chdir($tempDirectory); touch('test-file.php'); - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $input = new Input('app', ['program' => 'test-file.php']); - $listener = new RealPathListener; + $listener = new RealPathListener(); $listener->__invoke(new ExerciseRunnerEvent('some.event', $exercise, $input)); $this->assertEquals(sprintf('%s/test-file.php', $tempDirectory), $input->getArgument('program')); @@ -35,21 +35,21 @@ public function testInputArgumentIsReplacesWithAbsolutePathIfFileExists() : void chdir($current); } - public function testInputArgumentIsLeftUnchangedIfFileDoesNotExist() : void + public function testInputArgumentIsLeftUnchangedIfFileDoesNotExist(): void { - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $input = new Input('app', ['program' => 'test-file.php']); - $listener = new RealPathListener; + $listener = new RealPathListener(); $listener->__invoke(new ExerciseRunnerEvent('some.event', $exercise, $input)); $this->assertEquals('test-file.php', $input->getArgument('program')); } - public function testInputIsUnchangedIfNoProgramArgument() : void + public function testInputIsUnchangedIfNoProgramArgument(): void { - $exercise = new CliExerciseImpl; + $exercise = new CliExerciseImpl(); $input = new Input('app', ['some-arg' => 'some-value']); - $listener = new RealPathListener; + $listener = new RealPathListener(); $listener->__invoke(new ExerciseRunnerEvent('some.event', $exercise, $input)); $this->assertEquals('some-value', $input->getArgument('some-arg')); diff --git a/test/Listener/SelfCheckListenerTest.php b/test/Listener/SelfCheckListenerTest.php index 128cc11d..af10b249 100644 --- a/test/Listener/SelfCheckListenerTest.php +++ b/test/Listener/SelfCheckListenerTest.php @@ -18,7 +18,7 @@ */ class SelfCheckListenerTest extends TestCase { - public function testSelfCheck() : void + public function testSelfCheck(): void { $exercise = $this->createMock(SelfCheckExerciseInterface::class); $input = new Input('app', ['program' => 'some-file.php']); @@ -31,7 +31,7 @@ public function testSelfCheck() : void ->with($input) ->willReturn($success); - $results = new ResultAggregator; + $results = new ResultAggregator(); $listener = new SelfCheckListener($results); $listener->__invoke($event); @@ -39,13 +39,13 @@ public function testSelfCheck() : void $this->assertCount(1, $results); } - public function testExerciseWithOutSelfCheck() : void + public function testExerciseWithOutSelfCheck(): void { $exercise = $this->createMock(ExerciseInterface::class); $input = new Input('app', ['program' => 'some-file.php']); $event = new Event('event', compact('exercise', 'input')); - $results = new ResultAggregator; + $results = new ResultAggregator(); $listener = new SelfCheckListener($results); $listener->__invoke($event); diff --git a/test/MarkdownRendererTest.php b/test/MarkdownRendererTest.php index 414f94b6..e382ebff 100644 --- a/test/MarkdownRendererTest.php +++ b/test/MarkdownRendererTest.php @@ -16,7 +16,7 @@ */ class MarkdownRendererTest extends TestCase { - public function testRender() : void + public function testRender(): void { $docParser = new DocParser(Environment::createCommonMarkEnvironment()); $cliRenderer = (new CliRendererFactory())->__invoke(); diff --git a/test/MenuItem/ResetProgressTest.php b/test/MenuItem/ResetProgressTest.php index 7dc7e405..6e5a270c 100644 --- a/test/MenuItem/ResetProgressTest.php +++ b/test/MenuItem/ResetProgressTest.php @@ -20,7 +20,7 @@ */ class ResetProgressTest extends TestCase { - public function testResetProgressDisablesParentMenuItems() : void + public function testResetProgressDisablesParentMenuItems(): void { $item1 = $this->createMock(MenuItemInterface::class); $item2 = $this->createMock(MenuItemInterface::class); diff --git a/test/NodeVisitor/FunctionVisitorTest.php b/test/NodeVisitor/FunctionVisitorTest.php index ba64a548..4ef99fa3 100644 --- a/test/NodeVisitor/FunctionVisitorTest.php +++ b/test/NodeVisitor/FunctionVisitorTest.php @@ -14,7 +14,7 @@ */ class FunctionVisitorTest extends TestCase { - public function testLeaveNodeWithARequiredFunctionIsRecorded() : void + public function testLeaveNodeWithARequiredFunctionIsRecorded(): void { $node = new FuncCall(new Name('file_get_contents')); $visitor = new FunctionVisitor(['file_get_contents'], []); @@ -25,7 +25,7 @@ public function testLeaveNodeWithARequiredFunctionIsRecorded() : void $this->assertSame([], $visitor->getMissingRequirements()); } - public function testLeaveNodeWithARequiredFunctionIsNotRecorded() : void + public function testLeaveNodeWithARequiredFunctionIsNotRecorded(): void { $node = new FuncCall(new Name('file')); $visitor = new FunctionVisitor(['file_get_contents'], []); @@ -36,7 +36,7 @@ public function testLeaveNodeWithARequiredFunctionIsNotRecorded() : void $this->assertSame(['file_get_contents'], $visitor->getMissingRequirements()); } - public function testBannedUsagesAreRecorded() : void + public function testBannedUsagesAreRecorded(): void { $node = new FuncCall(new Name('file_get_contents')); $visitor = new FunctionVisitor([], ['file_get_contents']); @@ -46,7 +46,7 @@ public function testBannedUsagesAreRecorded() : void $this->assertSame([$node], $visitor->getBannedUsages()); } - public function testBannedUsagesAreNotRecorded() : void + public function testBannedUsagesAreNotRecorded(): void { $node = new FuncCall(new Name('file')); $visitor = new FunctionVisitor([], ['file_get_contents']); diff --git a/test/PatchTest.php b/test/PatchTest.php index e929de20..5e2298c2 100644 --- a/test/PatchTest.php +++ b/test/PatchTest.php @@ -13,9 +13,9 @@ */ class PatchTest extends TestCase { - public function testWithInsertion() : void + public function testWithInsertion(): void { - $patch = new Patch; + $patch = new Patch(); $insertion = new CodeInsertion(CodeInsertion::TYPE_BEFORE, 'MEH'); $new = $patch->withInsertion($insertion); @@ -24,9 +24,9 @@ public function testWithInsertion() : void $this->assertEquals([$insertion], $new->getModifiers()); } - public function testWithTransformer() : void + public function testWithTransformer(): void { - $patch = new Patch; + $patch = new Patch(); $transformer = function (array $statements) { return $statements; }; diff --git a/test/Result/Cgi/CgiResultTest.php b/test/Result/Cgi/CgiResultTest.php index 7885b856..792d7dc1 100644 --- a/test/Result/Cgi/CgiResultTest.php +++ b/test/Result/Cgi/CgiResultTest.php @@ -13,14 +13,14 @@ */ class CgiResultTest extends TestCase { - public function testName() : void + public function testName(): void { $request = new RequestFailure($this->createMock(RequestInterface::class), '', '', [], []); $cgiResult = new CgiResult([$request]); $this->assertSame('CGI Program Runner', $cgiResult->getCheckName()); } - public function testIsSuccessful() : void + public function testIsSuccessful(): void { $request = new RequestFailure($this->createMock(RequestInterface::class), '', '', [], []); $cgiResult = new CgiResult([$request]); diff --git a/test/Result/Cgi/GenericFailureTest.php b/test/Result/Cgi/GenericFailureTest.php index 0286da43..d97fd515 100644 --- a/test/Result/Cgi/GenericFailureTest.php +++ b/test/Result/Cgi/GenericFailureTest.php @@ -22,7 +22,7 @@ public function testFailure(): void $this->assertEquals('CGI Program Runner', $failure->getCheckName()); } - public function testFailureWithRequestAndReason() : void + public function testFailureWithRequestAndReason(): void { $request = $this->createMock(RequestInterface::class); $failure = GenericFailure::fromRequestAndReason($request, 'Oops'); @@ -32,7 +32,7 @@ public function testFailureWithRequestAndReason() : void $this->assertEquals('CGI Program Runner', $failure->getCheckName()); } - public function testFailureFromCodeExecutionException() : void + public function testFailureFromCodeExecutionException(): void { $e = new CodeExecutionException('Something went wrong yo'); $request = $this->createMock(RequestInterface::class); diff --git a/test/Result/Cgi/RequestFailureTest.php b/test/Result/Cgi/RequestFailureTest.php index f609da60..00079708 100644 --- a/test/Result/Cgi/RequestFailureTest.php +++ b/test/Result/Cgi/RequestFailureTest.php @@ -11,7 +11,7 @@ */ class RequestFailureTest extends TestCase { - public function setUp() : void + public function setUp(): void { $request = $this->createMock(RequestInterface::class); $requestFailure = new RequestFailure($request, '', '', [], []); @@ -19,7 +19,7 @@ public function setUp() : void $this->assertSame($request, $requestFailure->getRequest()); } - public function testWhenOnlyOutputDifferent() : void + public function testWhenOnlyOutputDifferent(): void { $requestFailure = new RequestFailure( $this->createMock(RequestInterface::class), @@ -37,7 +37,7 @@ public function testWhenOnlyOutputDifferent() : void $this->assertSame($requestFailure->getExpectedHeaders(), $requestFailure->getActualHeaders()); } - public function testWhenOnlyHeadersDifferent() : void + public function testWhenOnlyHeadersDifferent(): void { $requestFailure = new RequestFailure( $this->createMock(RequestInterface::class), @@ -55,7 +55,7 @@ public function testWhenOnlyHeadersDifferent() : void $this->assertSame($requestFailure->getExpectedOutput(), $requestFailure->getActualOutput()); } - public function testWhenOutputAndHeadersDifferent() : void + public function testWhenOutputAndHeadersDifferent(): void { $requestFailure = new RequestFailure( $this->createMock(RequestInterface::class), diff --git a/test/Result/Cgi/SuccessTest.php b/test/Result/Cgi/SuccessTest.php index 631e18c5..6173e951 100644 --- a/test/Result/Cgi/SuccessTest.php +++ b/test/Result/Cgi/SuccessTest.php @@ -11,7 +11,7 @@ */ class SuccessTest extends TestCase { - public function testSuccess() : void + public function testSuccess(): void { $request = $this->createMock(RequestInterface::class); $success = new Success($request); diff --git a/test/Result/Cli/CliResultTest.php b/test/Result/Cli/CliResultTest.php index 899269c6..e2e4bc26 100644 --- a/test/Result/Cli/CliResultTest.php +++ b/test/Result/Cli/CliResultTest.php @@ -13,21 +13,21 @@ */ class CliResultTest extends TestCase { - public function testName() : void + public function testName(): void { - $request = new RequestFailure(new ArrayObject, 'EXPECTED', 'ACTUAL'); + $request = new RequestFailure(new ArrayObject(), 'EXPECTED', 'ACTUAL'); $cliResult = new CliResult([$request]); $this->assertSame('CLI Program Runner', $cliResult->getCheckName()); } - public function testIsSuccessful() : void + public function testIsSuccessful(): void { - $request = new RequestFailure(new ArrayObject, 'EXPECTED', 'ACTUAL'); + $request = new RequestFailure(new ArrayObject(), 'EXPECTED', 'ACTUAL'); $cliResult = new CliResult([$request]); $this->assertFalse($cliResult->isSuccessful()); - $cliResult = new CliResult([new Success(new ArrayObject)]); + $cliResult = new CliResult([new Success(new ArrayObject())]); $this->assertTrue($cliResult->isSuccessful()); $cliResult->add($request); diff --git a/test/Result/Cli/GenericFailureTest.php b/test/Result/Cli/GenericFailureTest.php index b27c177e..4272ce90 100644 --- a/test/Result/Cli/GenericFailureTest.php +++ b/test/Result/Cli/GenericFailureTest.php @@ -12,9 +12,9 @@ */ class GenericFailureTest extends TestCase { - public function testFailure() : void + public function testFailure(): void { - $args = new ArrayObject; + $args = new ArrayObject(); $failure = new GenericFailure($args, 'Oops'); $this->assertInstanceOf(GenericFailure::class, $failure); $this->assertEquals($args, $failure->getArgs()); @@ -22,9 +22,9 @@ public function testFailure() : void $this->assertEquals('CLI Program Runner', $failure->getCheckName()); } - public function testFailureWithRequestAndReason() : void + public function testFailureWithRequestAndReason(): void { - $args = new ArrayObject; + $args = new ArrayObject(); $failure = GenericFailure::fromArgsAndReason($args, 'Oops'); $this->assertInstanceOf(GenericFailure::class, $failure); $this->assertEquals($args, $failure->getArgs()); @@ -32,9 +32,9 @@ public function testFailureWithRequestAndReason() : void $this->assertEquals('CLI Program Runner', $failure->getCheckName()); } - public function testFailureFromCodeExecutionException() : void + public function testFailureFromCodeExecutionException(): void { - $args = new ArrayObject; + $args = new ArrayObject(); $e = new CodeExecutionException('Something went wrong yo'); $failure = GenericFailure::fromArgsAndCodeExecutionFailure($args, $e); $this->assertInstanceOf(GenericFailure::class, $failure); diff --git a/test/Result/Cli/RequestFailureTest.php b/test/Result/Cli/RequestFailureTest.php index e0d7e72c..704a9f33 100644 --- a/test/Result/Cli/RequestFailureTest.php +++ b/test/Result/Cli/RequestFailureTest.php @@ -11,26 +11,26 @@ */ class RequestFailureTest extends TestCase { - public function setUp() : void + public function setUp(): void { - $args = new ArrayObject; + $args = new ArrayObject(); $failure = new RequestFailure($args, 'Expected Output', 'Actual Output'); $this->assertSame('Request Failure', $failure->getCheckName()); $this->assertSame($args, $failure->getArgs()); } - public function testGetters() : void + public function testGetters(): void { - $args = new ArrayObject; + $args = new ArrayObject(); $failure = new RequestFailure($args, 'Expected Output', 'Actual Output'); $this->assertEquals('Expected Output', $failure->getExpectedOutput()); $this->assertEquals('Actual Output', $failure->getActualOutput()); $this->assertSame($args, $failure->getArgs()); } - public function testFailureFromArgsAndOutput() : void + public function testFailureFromArgsAndOutput(): void { - $args = new ArrayObject; + $args = new ArrayObject(); $failure = RequestFailure::fromArgsAndOutput($args, 'Expected Output', 'Actual Output'); $this->assertEquals('Expected Output', $failure->getExpectedOutput()); $this->assertEquals('Actual Output', $failure->getActualOutput()); diff --git a/test/Result/Cli/SuccessTest.php b/test/Result/Cli/SuccessTest.php index f87b3e84..ba9f5327 100644 --- a/test/Result/Cli/SuccessTest.php +++ b/test/Result/Cli/SuccessTest.php @@ -11,9 +11,9 @@ */ class SuccessTest extends TestCase { - public function testSuccess() : void + public function testSuccess(): void { - $args = new ArrayObject; + $args = new ArrayObject(); $success = new Success($args); $this->assertInstanceOf(Success::class, $success); $this->assertSame($args, $success->getArgs()); diff --git a/test/Result/ComparisonFailureTest.php b/test/Result/ComparisonFailureTest.php index 98c04325..a3b39130 100644 --- a/test/Result/ComparisonFailureTest.php +++ b/test/Result/ComparisonFailureTest.php @@ -10,7 +10,7 @@ */ class ComparisonFailureTest extends TestCase { - public function testGetters() : void + public function testGetters(): void { $failure = new ComparisonFailure('Name', 'Expected Output', 'Actual Output'); self::assertSame('Name', $failure->getCheckName()); @@ -18,7 +18,7 @@ public function testGetters() : void self::assertEquals('Actual Output', $failure->getActualValue()); } - public function testFailureFromArgsAndOutput() : void + public function testFailureFromArgsAndOutput(): void { $failure = ComparisonFailure::fromNameAndValues('Name', 'Expected Output', 'Actual Output'); self::assertSame('Name', $failure->getCheckName()); diff --git a/test/Result/FailureTest.php b/test/Result/FailureTest.php index f2a9b1b1..abad5139 100644 --- a/test/Result/FailureTest.php +++ b/test/Result/FailureTest.php @@ -21,7 +21,7 @@ class FailureTest extends TestCase */ private $check; - public function setUp() : void + public function setUp(): void { $this->check = $this->createMock(CheckInterface::class); $this->check @@ -32,7 +32,7 @@ public function setUp() : void $this->assertSame('Some Check', $failure->getCheckName()); } - public function testFailure() : void + public function testFailure(): void { $failure = new Failure($this->check->getName(), 'Something went wrong yo'); $this->assertInstanceOf(ResultInterface::class, $failure); @@ -40,7 +40,7 @@ public function testFailure() : void $this->assertEquals('Some Check', $failure->getCheckName()); } - public function testFailureWithNameAndReason() : void + public function testFailureWithNameAndReason(): void { $failure = Failure::fromNameAndReason('Some Check', 'Something went wrong yo'); $this->assertInstanceOf(ResultInterface::class, $failure); @@ -48,7 +48,7 @@ public function testFailureWithNameAndReason() : void $this->assertEquals('Some Check', $failure->getCheckName()); } - public function testFailureWithReason() : void + public function testFailureWithReason(): void { $failure = Failure::fromCheckAndReason($this->check, 'Something went wrong yo'); $this->assertInstanceOf(ResultInterface::class, $failure); @@ -56,7 +56,7 @@ public function testFailureWithReason() : void $this->assertEquals('Some Check', $failure->getCheckName()); } - public function testFailureFromCodeExecutionException() : void + public function testFailureFromCodeExecutionException(): void { $e = new CodeExecutionException('Something went wrong yo'); $failure = Failure::fromNameAndCodeExecutionFailure('Some Check', $e); @@ -65,7 +65,7 @@ public function testFailureFromCodeExecutionException() : void $this->assertEquals('Some Check', $failure->getCheckName()); } - public function testFailureFromCodeParseException() : void + public function testFailureFromCodeParseException(): void { $e = new Error('Something went wrong yo'); $failure = Failure::fromCheckAndCodeParseFailure($this->check, $e, 'exercise.php'); diff --git a/test/Result/FunctionRequirementsFailureTest.php b/test/Result/FunctionRequirementsFailureTest.php index f5bbc122..1ee07990 100644 --- a/test/Result/FunctionRequirementsFailureTest.php +++ b/test/Result/FunctionRequirementsFailureTest.php @@ -13,7 +13,7 @@ */ class FunctionRequirementsFailureTest extends TestCase { - public function testGetters() : void + public function testGetters(): void { $check = $this->createMock(CheckInterface::class); $check diff --git a/test/Result/SuccessTest.php b/test/Result/SuccessTest.php index 54c45f39..28176c56 100644 --- a/test/Result/SuccessTest.php +++ b/test/Result/SuccessTest.php @@ -14,14 +14,14 @@ */ class SuccessTest extends TestCase { - public function testSuccess() : void + public function testSuccess(): void { $success = new Success('Some Check'); $this->assertInstanceOf(ResultInterface::class, $success); $this->assertEquals('Some Check', $success->getCheckName()); } - public function testSuccessFromCheck() : void + public function testSuccessFromCheck(): void { $check = $this->createMock(CheckInterface::class); $check diff --git a/test/ResultAggregatorTest.php b/test/ResultAggregatorTest.php index d19e66f8..9aa236a5 100644 --- a/test/ResultAggregatorTest.php +++ b/test/ResultAggregatorTest.php @@ -1,6 +1,5 @@ check = $this->createMock(CheckInterface::class); $this->check @@ -33,9 +32,9 @@ public function setUp() : void ->willReturn('Some Check'); } - public function testIsSuccessful() : void + public function testIsSuccessful(): void { - $resultAggregator = new ResultAggregator; + $resultAggregator = new ResultAggregator(); $this->assertTrue($resultAggregator->isSuccessful()); $resultAggregator->add(new Success($this->check)); @@ -45,30 +44,30 @@ public function testIsSuccessful() : void $this->assertFalse($resultAggregator->isSuccessful()); } - public function testIsSuccessfulWithResultGroups() : void + public function testIsSuccessfulWithResultGroups(): void { - $resultAggregator = new ResultAggregator; + $resultAggregator = new ResultAggregator(); $this->assertTrue($resultAggregator->isSuccessful()); - $resultGroup = new CliResult; - $resultGroup->add(new CliSuccess(new ArrayObject)); + $resultGroup = new CliResult(); + $resultGroup->add(new CliSuccess(new ArrayObject())); $resultAggregator->add($resultGroup); $this->assertTrue($resultAggregator->isSuccessful()); - $resultGroup->add(new CliGenericFailure(new ArrayObject, 'nop')); + $resultGroup->add(new CliGenericFailure(new ArrayObject(), 'nop')); $this->assertFalse($resultAggregator->isSuccessful()); } - public function testIterator() : void + public function testIterator(): void { $results = [ new Success($this->check), new Failure($this->check, 'nope') ]; - $resultAggregator = new ResultAggregator; + $resultAggregator = new ResultAggregator(); $resultAggregator->add($results[0]); $resultAggregator->add($results[1]); diff --git a/test/ResultRenderer/AbstractResultRendererTest.php b/test/ResultRenderer/AbstractResultRendererTest.php index dbd04bbd..568e0acf 100644 --- a/test/ResultRenderer/AbstractResultRendererTest.php +++ b/test/ResultRenderer/AbstractResultRendererTest.php @@ -33,7 +33,7 @@ abstract class AbstractResultRendererTest extends TestCase public function getResultRendererFactory(): ResultRendererFactory { if (null === $this->resultRendererFactory) { - $this->resultRendererFactory = new ResultRendererFactory; + $this->resultRendererFactory = new ResultRendererFactory(); } return $this->resultRendererFactory; @@ -45,7 +45,7 @@ public function getResultRendererFactory(): ResultRendererFactory protected function getRenderer(): ResultsRenderer { if (null === $this->renderer) { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $terminal = $this->prophesize(Terminal::class); @@ -57,7 +57,7 @@ protected function getRenderer(): ResultsRenderer $color, $terminal->reveal(), $exerciseRepo, - new KeyLighter, + new KeyLighter(), $this->getResultRendererFactory() ); } diff --git a/test/ResultRenderer/Cgi/RequestFailureRendererTest.php b/test/ResultRenderer/Cgi/RequestFailureRendererTest.php index c50af05b..2ddd4ac2 100644 --- a/test/ResultRenderer/Cgi/RequestFailureRendererTest.php +++ b/test/ResultRenderer/Cgi/RequestFailureRendererTest.php @@ -12,7 +12,7 @@ */ class RequestFailureRendererTest extends AbstractResultRendererTest { - public function testRenderWhenOnlyHeadersDifferent() : void + public function testRenderWhenOnlyHeadersDifferent(): void { $failure = new RequestFailure( $this->request(), @@ -31,7 +31,7 @@ public function testRenderWhenOnlyHeadersDifferent() : void $this->assertSame($expected, $renderer->render($this->getRenderer())); } - public function testRenderWhenOnlyOutputDifferent() : void + public function testRenderWhenOnlyOutputDifferent(): void { $failure = new RequestFailure( $this->request(), @@ -49,7 +49,7 @@ public function testRenderWhenOnlyOutputDifferent() : void $this->assertSame($expected, $renderer->render($this->getRenderer())); } - public function testRenderWhenOutputAndHeadersDifferent() : void + public function testRenderWhenOutputAndHeadersDifferent(): void { $failure = new RequestFailure( $this->request(), @@ -73,7 +73,7 @@ public function testRenderWhenOutputAndHeadersDifferent() : void $this->assertSame($expected, $renderer->render($this->getRenderer())); } - private function request() : Request + private function request(): Request { return (new Request('http://www.test.com')) ->withMethod('POST') diff --git a/test/ResultRenderer/CgiResultRendererTest.php b/test/ResultRenderer/CgiResultRendererTest.php index ddcb5c19..8f8e8562 100644 --- a/test/ResultRenderer/CgiResultRendererTest.php +++ b/test/ResultRenderer/CgiResultRendererTest.php @@ -17,15 +17,15 @@ */ class CgiResultRendererTest extends AbstractResultRendererTest { - public function testNothingIsOutputIfNoFailures() : void + public function testNothingIsOutputIfNoFailures(): void { $result = new CgiResult([new Success($this->request())]); - $renderer = new CgiResultRenderer($result, new RequestRenderer); + $renderer = new CgiResultRenderer($result, new RequestRenderer()); $this->assertEmpty($renderer->render($this->getRenderer())); } - public function testRenderWithFailedRequest() : void + public function testRenderWithFailedRequest(): void { $failureRenderer = $this->prophesize(RequestFailureRenderer::class); $failureRenderer->render($this->getRenderer())->willReturn("REQUEST FAILURE\n"); @@ -46,7 +46,7 @@ function (RequestFailure $failure) use ($failureRenderer) { ['header1' => 'val'] ); $result = new CgiResult([$failure]); - $renderer = new CgiResultRenderer($result, new RequestRenderer); + $renderer = new CgiResultRenderer($result, new RequestRenderer()); $expected = "Some requests to your solution produced incorrect output!\n"; $expected .= "\e[33m──────────────────────────────────────────────────\e[0m\n"; @@ -63,7 +63,7 @@ function (RequestFailure $failure) use ($failureRenderer) { $this->assertSame($expected, $renderer->render($this->getRenderer())); } - public function testMultipleFailedRequests() : void + public function testMultipleFailedRequests(): void { $failureRenderer = $this->prophesize(RequestFailureRenderer::class); $failureRenderer->render($this->getRenderer())->willReturn("REQUEST FAILURE\n"); @@ -92,7 +92,7 @@ function (RequestFailure $failure) use ($failureRenderer) { ['header1' => 'val'] ); $result = new CgiResult([$failure1, $failure2]); - $renderer = new CgiResultRenderer($result, new RequestRenderer); + $renderer = new CgiResultRenderer($result, new RequestRenderer()); $expected = "Some requests to your solution produced incorrect output!\n"; $expected .= "\e[33m──────────────────────────────────────────────────\e[0m\n"; @@ -121,7 +121,7 @@ function (RequestFailure $failure) use ($failureRenderer) { $this->assertSame($expected, $renderer->render($this->getRenderer())); } - public function testRenderWithFailedRequestAndSuccess() : void + public function testRenderWithFailedRequestAndSuccess(): void { $failureRenderer = $this->prophesize(RequestFailureRenderer::class); $failureRenderer->render($this->getRenderer())->willReturn("REQUEST FAILURE\n"); @@ -142,7 +142,7 @@ function (RequestFailure $failure) use ($failureRenderer) { ['header1' => 'val'] ); $result = new CgiResult([$failure, new Success($this->request())]); - $renderer = new CgiResultRenderer($result, new RequestRenderer); + $renderer = new CgiResultRenderer($result, new RequestRenderer()); $expected = "Some requests to your solution produced incorrect output!\n"; $expected .= "\e[33m──────────────────────────────────────────────────\e[0m\n"; @@ -159,7 +159,7 @@ function (RequestFailure $failure) use ($failureRenderer) { $this->assertSame($expected, $renderer->render($this->getRenderer())); } - public function testRenderWithFailedRequestAndGenericFailure() : void + public function testRenderWithFailedRequestAndGenericFailure(): void { $requestFailureRenderer = $this->prophesize(RequestFailureRenderer::class); @@ -194,7 +194,7 @@ function (GenericFailure $failure) use ($genericFailureRenderer) { $codeExecutionFailure = new GenericFailure($this->request(), 'Code Execution Failure'); $result = new CgiResult([$failure, $codeExecutionFailure]); - $renderer = new CgiResultRenderer($result, new RequestRenderer); + $renderer = new CgiResultRenderer($result, new RequestRenderer()); $expected = "Some requests to your solution produced incorrect output!\n"; $expected .= "\e[33m──────────────────────────────────────────────────\e[0m\n"; @@ -223,7 +223,7 @@ function (GenericFailure $failure) use ($genericFailureRenderer) { $this->assertSame($expected, $renderer->render($this->getRenderer())); } - private function request() : Request + private function request(): Request { return (new Request('http://www.test.com')) ->withMethod('POST') diff --git a/test/ResultRenderer/Cli/RequestFailureRendererTest.php b/test/ResultRenderer/Cli/RequestFailureRendererTest.php index 79ef2360..09cbe45f 100644 --- a/test/ResultRenderer/Cli/RequestFailureRendererTest.php +++ b/test/ResultRenderer/Cli/RequestFailureRendererTest.php @@ -12,9 +12,9 @@ */ class RequestFailureRendererTest extends AbstractResultRendererTest { - public function testRender() : void + public function testRender(): void { - $failure = new RequestFailure(new ArrayObject, 'EXPECTED OUTPUT', 'ACTUAL OUTPUT'); + $failure = new RequestFailure(new ArrayObject(), 'EXPECTED OUTPUT', 'ACTUAL OUTPUT'); $renderer = new RequestFailureRenderer($failure); $expected = " \e[33m\e[1mYOUR OUTPUT:\e[0m\e[0m\n"; diff --git a/test/ResultRenderer/CliResultRendererTest.php b/test/ResultRenderer/CliResultRendererTest.php index ace0186c..a48cf1d0 100644 --- a/test/ResultRenderer/CliResultRendererTest.php +++ b/test/ResultRenderer/CliResultRendererTest.php @@ -14,15 +14,15 @@ */ class CliResultRendererTest extends AbstractResultRendererTest { - public function testNothingIsOutputIfNoFailures() : void + public function testNothingIsOutputIfNoFailures(): void { - $result = new CliResult([new Success(new ArrayObject)]); + $result = new CliResult([new Success(new ArrayObject())]); $renderer = new CliResultRenderer($result); $this->assertEmpty($renderer->render($this->getRenderer())); } - public function testRenderWithFailedRequest() : void + public function testRenderWithFailedRequest(): void { $failureRenderer = $this->prophesize(RequestFailureRenderer::class); $failureRenderer->render($this->getRenderer())->willReturn("REQUEST FAILURE\n"); @@ -36,7 +36,7 @@ function (RequestFailure $failure) use ($failureRenderer) { ); $failure = new RequestFailure( - new ArrayObject, + new ArrayObject(), 'EXPECTED OUTPUT', 'ACTUAL OUTPUT' ); @@ -52,7 +52,7 @@ function (RequestFailure $failure) use ($failureRenderer) { $this->assertSame($expected, $renderer->render($this->getRenderer())); } - public function testRenderWithFailedRequestWithMultipleArgs() : void + public function testRenderWithFailedRequestWithMultipleArgs(): void { $failureRenderer = $this->prophesize(RequestFailureRenderer::class); $failureRenderer->render($this->getRenderer())->willReturn("REQUEST FAILURE\n"); diff --git a/test/ResultRenderer/ComparisonFailureRendererTest.php b/test/ResultRenderer/ComparisonFailureRendererTest.php index 8b85d1ff..325bb121 100644 --- a/test/ResultRenderer/ComparisonFailureRendererTest.php +++ b/test/ResultRenderer/ComparisonFailureRendererTest.php @@ -10,7 +10,7 @@ */ class ComparisonFailureRendererTest extends AbstractResultRendererTest { - public function testRender() : void + public function testRender(): void { $failure = new ComparisonFailure('Name', 'EXPECTED OUTPUT', 'ACTUAL OUTPUT'); $renderer = new ComparisonFailureRenderer($failure); diff --git a/test/ResultRenderer/FailureRendererTest.php b/test/ResultRenderer/FailureRendererTest.php index 3721a79b..c539df67 100644 --- a/test/ResultRenderer/FailureRendererTest.php +++ b/test/ResultRenderer/FailureRendererTest.php @@ -13,7 +13,7 @@ */ class FailureRendererTest extends AbstractResultRendererTest { - public function testRender() : void + public function testRender(): void { $failure = new Failure($this->createMock(CheckInterface::class), 'Something went wrong'); $renderer = new FailureRenderer($failure); diff --git a/test/ResultRenderer/FunctionRequirementsFailureRendererTest.php b/test/ResultRenderer/FunctionRequirementsFailureRendererTest.php index 53a4217e..f5ae0e3c 100644 --- a/test/ResultRenderer/FunctionRequirementsFailureRendererTest.php +++ b/test/ResultRenderer/FunctionRequirementsFailureRendererTest.php @@ -14,7 +14,7 @@ */ class FunctionRequirementsFailureRendererTest extends AbstractResultRendererTest { - public function testRenderer() : void + public function testRenderer(): void { $failure = new FunctionRequirementsFailure( $this->createMock(CheckInterface::class), diff --git a/test/ResultRenderer/ResultsRendererTest.php b/test/ResultRenderer/ResultsRendererTest.php index ef341190..c4412b9d 100644 --- a/test/ResultRenderer/ResultsRendererTest.php +++ b/test/ResultRenderer/ResultsRendererTest.php @@ -29,12 +29,12 @@ */ class ResultsRendererTest extends TestCase { - public function testRenderIndividualResult() : void + public function testRenderIndividualResult(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); - $resultRendererFactory = new ResultRendererFactory; + $resultRendererFactory = new ResultRendererFactory(); $resultRendererFactory->registerRenderer(Failure::class, FailureRenderer::class); $terminal = $this->prophesize(Terminal::class); @@ -45,7 +45,7 @@ public function testRenderIndividualResult() : void $color, $terminal->reveal(), new ExerciseRepository([]), - new KeyLighter, + new KeyLighter(), $resultRendererFactory ); @@ -54,9 +54,9 @@ public function testRenderIndividualResult() : void $this->assertSame(" Some Failure\n", $renderer->renderResult($result)); } - public function testLineBreak() : void + public function testLineBreak(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); $terminal = $this->prophesize(Terminal::class); @@ -67,19 +67,19 @@ public function testLineBreak() : void $color, $terminal->reveal(), new ExerciseRepository([]), - new KeyLighter, - new ResultRendererFactory + new KeyLighter(), + new ResultRendererFactory() ); $this->assertSame("\e[33m──────────\e[0m", $renderer->lineBreak()); } - public function testRenderSuccess() : void + public function testRenderSuccess(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); - $resultRendererFactory = new ResultRendererFactory; + $resultRendererFactory = new ResultRendererFactory(); $terminal = $this->prophesize(Terminal::class); $terminal->getWidth()->willReturn(100); @@ -93,11 +93,11 @@ public function testRenderSuccess() : void $color, $terminal, $exerciseRepo->reveal(), - new KeyLighter, + new KeyLighter(), $resultRendererFactory ); - $resultSet = new ResultAggregator; + $resultSet = new ResultAggregator(); $resultSet->add(new Success('Success 1!')); $resultSet->add(new Success('Success 2!')); @@ -111,12 +111,12 @@ public function testRenderSuccess() : void ); } - public function testRenderSuccessWithSolution() : void + public function testRenderSuccessWithSolution(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); - $resultRendererFactory = new ResultRendererFactory; + $resultRendererFactory = new ResultRendererFactory(); $terminal = $this->prophesize(Terminal::class); $terminal->getWidth()->willReturn(100); @@ -140,11 +140,11 @@ public function testRenderSuccessWithSolution() : void $color, $terminal, $exerciseRepo->reveal(), - new KeyLighter, + new KeyLighter(), $resultRendererFactory ); - $resultSet = new ResultAggregator; + $resultSet = new ResultAggregator(); $resultSet->add(new Success('Success 1!')); $resultSet->add(new Success('Success 2!')); @@ -161,12 +161,12 @@ public function testRenderSuccessWithSolution() : void rmdir(dirname($tmpFile)); } - public function testRenderSuccessWithPhpSolutionFileIsSyntaxHighlighted() : void + public function testRenderSuccessWithPhpSolutionFileIsSyntaxHighlighted(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); - $resultRendererFactory = new ResultRendererFactory; + $resultRendererFactory = new ResultRendererFactory(); $terminal = $this->prophesize(Terminal::class); $terminal->getWidth()->willReturn(100); @@ -186,7 +186,7 @@ public function testRenderSuccessWithPhpSolutionFileIsSyntaxHighlighted() : void $exercise->getSolution()->willReturn($solution); $syntaxHighlighter = $this->prophesize(KeyLighter::class); - $php = new Php; + $php = new Php(); $syntaxHighlighter->languageByExt('.php')->willReturn($php); $syntaxHighlighter ->highlight('FILE CONTENTS', $php, Argument::type(CliFormatter::class)) @@ -201,7 +201,7 @@ public function testRenderSuccessWithPhpSolutionFileIsSyntaxHighlighted() : void $resultRendererFactory ); - $resultSet = new ResultAggregator; + $resultSet = new ResultAggregator(); $resultSet->add(new Success('Success 1!')); $resultSet->add(new Success('Success 2!')); @@ -218,12 +218,12 @@ public function testRenderSuccessWithPhpSolutionFileIsSyntaxHighlighted() : void rmdir(dirname($tmpFile)); } - public function testRenderSuccessAndFailure() : void + public function testRenderSuccessAndFailure(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); - $resultRendererFactory = new ResultRendererFactory; + $resultRendererFactory = new ResultRendererFactory(); $resultRendererFactory->registerRenderer(Failure::class, FailureRenderer::class, function (Failure $failure) { $renderer = $this->prophesize(FailureRenderer::class); $renderer->render(Argument::type(ResultsRenderer::class))->willReturn($failure->getReason() . "\n"); @@ -242,11 +242,11 @@ public function testRenderSuccessAndFailure() : void $color, $terminal, $exerciseRepo->reveal(), - new KeyLighter, + new KeyLighter(), $resultRendererFactory ); - $resultSet = new ResultAggregator; + $resultSet = new ResultAggregator(); $resultSet->add(new Success('Success 1!')); $resultSet->add(new Failure('Check 1', 'Failure')); $resultSet->add(new Failure('Check 2', 'Failure')); @@ -256,17 +256,17 @@ public function testRenderSuccessAndFailure() : void $renderer->render( $resultSet, $this->createMock(ExerciseInterface::class), - new UserState, + new UserState(), new StdOutput($color, $terminal) ); } - public function testAllSuccessResultsAreHoistedToTheTop() : void + public function testAllSuccessResultsAreHoistedToTheTop(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); - $resultRendererFactory = new ResultRendererFactory; + $resultRendererFactory = new ResultRendererFactory(); $resultRendererFactory->registerRenderer(Failure::class, FailureRenderer::class, function (Failure $failure) { $renderer = $this->prophesize(FailureRenderer::class); $renderer->render(Argument::type(ResultsRenderer::class))->willReturn($failure->getReason() . "\n"); @@ -285,11 +285,11 @@ public function testAllSuccessResultsAreHoistedToTheTop() : void $color, $terminal, $exerciseRepo->reveal(), - new KeyLighter, + new KeyLighter(), $resultRendererFactory ); - $resultSet = new ResultAggregator; + $resultSet = new ResultAggregator(); $resultSet->add(new Failure('Failure 1', 'Failure 1')); $resultSet->add(new Success('Success 1!')); $resultSet->add(new Failure('Failure 2', 'Failure 2')); @@ -300,17 +300,17 @@ public function testAllSuccessResultsAreHoistedToTheTop() : void $renderer->render( $resultSet, $this->createMock(ExerciseInterface::class), - new UserState, + new UserState(), new StdOutput($color, $terminal) ); } - public function testRenderAllFailures() : void + public function testRenderAllFailures(): void { - $color = new Color; + $color = new Color(); $color->setForceStyle(true); - $resultRendererFactory = new ResultRendererFactory; + $resultRendererFactory = new ResultRendererFactory(); $resultRendererFactory->registerRenderer(Failure::class, FailureRenderer::class, function (Failure $failure) { $renderer = $this->prophesize(FailureRenderer::class); $renderer->render(Argument::type(ResultsRenderer::class))->willReturn($failure->getReason() . "\n"); @@ -329,11 +329,11 @@ public function testRenderAllFailures() : void $color, $terminal, $exerciseRepo->reveal(), - new KeyLighter, + new KeyLighter(), $resultRendererFactory ); - $resultSet = new ResultAggregator; + $resultSet = new ResultAggregator(); $resultSet->add(new Failure('Failure 1', 'Failure 1')); $resultSet->add(new Failure('Failure 2', 'Failure 2')); @@ -342,12 +342,12 @@ public function testRenderAllFailures() : void $renderer->render( $resultSet, $this->createMock(ExerciseInterface::class), - new UserState, + new UserState(), new StdOutput($color, $terminal) ); } - private function getExpectedOutput() : string + private function getExpectedOutput(): string { $name = camel_case_to_kebab_case($this->getName()); return file_get_contents(sprintf('%s/../res/exercise-renderer/%s.txt', __DIR__, $name)); diff --git a/test/Solution/DirectorySolutionTest.php b/test/Solution/DirectorySolutionTest.php index 69c74311..140f531d 100644 --- a/test/Solution/DirectorySolutionTest.php +++ b/test/Solution/DirectorySolutionTest.php @@ -14,7 +14,7 @@ */ class DirectorySolutionTest extends TestCase { - public function testExceptionIsThrownIfEntryPointDoesNotExist() : void + public function testExceptionIsThrownIfEntryPointDoesNotExist(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); @@ -29,7 +29,7 @@ public function testExceptionIsThrownIfEntryPointDoesNotExist() : void rmdir($tempPath); } - public function testWithDefaultEntryPoint() : void + public function testWithDefaultEntryPoint(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); @@ -52,7 +52,7 @@ public function testWithDefaultEntryPoint() : void rmdir($tempPath); } - public function testWithManualEntryPoint() : void + public function testWithManualEntryPoint(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); @@ -75,7 +75,7 @@ public function testWithManualEntryPoint() : void rmdir($tempPath); } - public function testHasComposerFileReturnsTrueIfPresent() : void + public function testHasComposerFileReturnsTrueIfPresent(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); @@ -99,7 +99,7 @@ public function testHasComposerFileReturnsTrueIfPresent() : void unlink(sprintf('%s/some-class.php', $tempPath)); } - public function testWithExceptions() : void + public function testWithExceptions(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); @@ -124,7 +124,7 @@ public function testWithExceptions() : void rmdir($tempPath); } - public function testWithNestedDirectories() : void + public function testWithNestedDirectories(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); @@ -160,7 +160,7 @@ public function testWithNestedDirectories() : void rmdir($tempPath); } - public function testExceptionsWithNestedDirectories() : void + public function testExceptionsWithNestedDirectories(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); diff --git a/test/Solution/SingleFileSolutionTest.php b/test/Solution/SingleFileSolutionTest.php index 0049f2bc..c39fe5cd 100644 --- a/test/Solution/SingleFileSolutionTest.php +++ b/test/Solution/SingleFileSolutionTest.php @@ -12,7 +12,7 @@ */ class SingleFileSolutionTest extends TestCase { - public function testGetters() : void + public function testGetters(): void { $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); $filePath = sprintf('%s/test.file', $tempPath); diff --git a/test/Solution/SolutionFileTest.php b/test/Solution/SolutionFileTest.php index 64e8bae7..2d06b257 100644 --- a/test/Solution/SolutionFileTest.php +++ b/test/Solution/SolutionFileTest.php @@ -13,7 +13,7 @@ */ class SolutionFileTest extends TestCase { - public function testExceptionIsThrowIfFileNotExists() : void + public function testExceptionIsThrowIfFileNotExists(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('File: "file/that/does/not/exist.php" does not exist'); @@ -21,7 +21,7 @@ public function testExceptionIsThrowIfFileNotExists() : void SolutionFile::fromFile('file/that/does/not/exist.php'); } - public function testPaths() : void + public function testPaths(): void { $tempPath = sprintf('%s/%s', sys_get_temp_dir(), $this->getName()); $filePath = sprintf('%s/test.file', $tempPath); @@ -39,7 +39,7 @@ public function testPaths() : void rmdir($tempPath); } - public function testEmptyContents() : void + public function testEmptyContents(): void { $tempPath = sprintf('%s/%s', sys_get_temp_dir(), $this->getName()); $filePath = sprintf('%s/test.file', $tempPath); @@ -57,7 +57,7 @@ public function testEmptyContents() : void rmdir($tempPath); } - public function testGetContents() : void + public function testGetContents(): void { $tempPath = sprintf('%s/%s', sys_get_temp_dir(), $this->getName()); $filePath = sprintf('%s/test.file', $tempPath); @@ -75,7 +75,7 @@ public function testGetContents() : void rmdir($tempPath); } - public function testConstructionWithManualBaseDirectory() : void + public function testConstructionWithManualBaseDirectory(): void { $tempPath = sprintf('%s/%s/sub-dir', sys_get_temp_dir(), $this->getName()); $filePath = sprintf('%s/test.file', $tempPath); @@ -93,7 +93,7 @@ public function testConstructionWithManualBaseDirectory() : void rmdir($tempPath); } - public function testGetExtension() : void + public function testGetExtension(): void { $tempPath = sprintf('%s/%s/sub-dir', sys_get_temp_dir(), $this->getName()); $filePath = sprintf('%s/test.php', $tempPath); diff --git a/test/TestWorkshopType.php b/test/TestWorkshopType.php index 345e7bff..c9cf3d2d 100644 --- a/test/TestWorkshopType.php +++ b/test/TestWorkshopType.php @@ -11,7 +11,7 @@ */ class TestWorkshopType extends TestCase { - public function testIsTutorialMode() : void + public function testIsTutorialMode(): void { $tutorial = WorkshopType::TUTORIAL(); $standard = WorkshopType::STANDARD(); diff --git a/test/UserStateSerializerTest.php b/test/UserStateSerializerTest.php index 36dcf436..5bccaeb9 100644 --- a/test/UserStateSerializerTest.php +++ b/test/UserStateSerializerTest.php @@ -36,33 +36,33 @@ class UserStateSerializerTest extends TestCase */ private $exerciseRepository; - public function setUp() : void + public function setUp(): void { $this->tmpDir = sprintf('%s/%s/%s', sys_get_temp_dir(), $this->getName(), random_int(1, 100)); $this->tmpFile = sprintf('%s/.phpschool-save.json', $this->tmpDir); $this->exerciseRepository = new ExerciseRepository([]); } - public function testIfDirNotExistsItIsCreated() : void + public function testIfDirNotExistsItIsCreated(): void { $this->assertFileDoesNotExist($this->tmpDir); new UserStateSerializer($this->tmpDir, $this->workshopName, $this->exerciseRepository); $this->assertFileExists($this->tmpDir); } - public function testConstructWhenFileExists() : void + public function testConstructWhenFileExists(): void { mkdir($this->tmpDir, 0777, true); $this->assertFileExists($this->tmpDir); new UserStateSerializer($this->tmpDir, $this->workshopName, $this->exerciseRepository); } - public function testSerializeEmptySate() : void + public function testSerializeEmptySate(): void { mkdir($this->tmpDir, 0777, true); $serializer = new UserStateSerializer($this->tmpDir, $this->workshopName, $this->exerciseRepository); - $state = new UserState; + $state = new UserState(); $expected = json_encode([ 'My Workshop' => [ @@ -76,7 +76,7 @@ public function testSerializeEmptySate() : void $this->assertSame($expected, file_get_contents($this->tmpFile)); } - public function testSerialize() : void + public function testSerialize(): void { mkdir($this->tmpDir, 0777, true); $serializer = new UserStateSerializer($this->tmpDir, $this->workshopName, $this->exerciseRepository); @@ -96,7 +96,7 @@ public function testSerialize() : void $this->assertSame($expected, file_get_contents($this->tmpFile)); } - public function testDeserializeNonExistingFile() : void + public function testDeserializeNonExistingFile(): void { mkdir($this->tmpDir, 0777, true); $serializer = new UserStateSerializer($this->tmpDir, $this->workshopName, $this->exerciseRepository); @@ -105,7 +105,7 @@ public function testDeserializeNonExistingFile() : void $this->assertEmpty($state->getCompletedExercises()); } - public function testDeserializeEmptyFile() : void + public function testDeserializeEmptyFile(): void { mkdir($this->tmpDir, 0777, true); file_put_contents($this->tmpFile, ''); @@ -115,7 +115,7 @@ public function testDeserializeEmptyFile() : void $this->assertEmpty($state->getCompletedExercises()); } - public function testDeserializeNonValidJson() : void + public function testDeserializeNonValidJson(): void { mkdir($this->tmpDir, 0777, true); file_put_contents($this->tmpFile, 'yayayayayanotjson'); @@ -128,7 +128,7 @@ public function testDeserializeNonValidJson() : void /** * @dataProvider deserializerProvider */ - public function testDeserialize(array $data, array $expected) : void + public function testDeserialize(array $data, array $expected): void { mkdir($this->tmpDir, 0777, true); file_put_contents($this->tmpFile, json_encode($data)); @@ -144,7 +144,7 @@ public function testDeserialize(array $data, array $expected) : void rmdir($this->tmpDir); } - public function deserializerProvider() : array + public function deserializerProvider(): array { return [ 'empty-array' => [ @@ -172,7 +172,7 @@ public function deserializerProvider() : array ['completed_exercises' => [], 'current_exercise' => null] ], 'completed-exercise-invalid-current-exercise' => [ - ['My Workshop' => ['completed_exercises' => ['exercise1'], 'current_exercise' => new \stdClass]], + ['My Workshop' => ['completed_exercises' => ['exercise1'], 'current_exercise' => new \stdClass()]], ['completed_exercises' => ['exercise1'], 'current_exercise' => null] ], 'completed-exercise-current-null' => [ @@ -186,7 +186,7 @@ public function deserializerProvider() : array ]; } - public function testOldDataWillBeMigratedWhenInCorrectWorkshop() : void + public function testOldDataWillBeMigratedWhenInCorrectWorkshop(): void { $oldSave = sprintf('%s/.phpschool.json', $this->tmpDir); $newSave = sprintf('%s/.phpschool-save.json', $this->tmpDir); @@ -231,7 +231,7 @@ public function testOldDataWillBeMigratedWhenInCorrectWorkshop() : void $this->assertEquals($expected, json_decode(file_get_contents($newSave), true)); } - public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshop() : void + public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshop(): void { $oldSave = sprintf('%s/.phpschool.json', $this->tmpDir); $newSave = sprintf('%s/.phpschool-save.json', $this->tmpDir); @@ -270,7 +270,7 @@ public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshop() : void unlink($oldSave); } - public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshopWithOtherWorkshop() : void + public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshopWithOtherWorkshop(): void { $oldSave = sprintf('%s/.phpschool.json', $this->tmpDir); $newSave = sprintf('%s/.phpschool-save.json', $this->tmpDir); @@ -325,7 +325,7 @@ public function testOldDataWillNotBeMigratedWhenNotInCorrectWorkshopWithOtherWor unlink($oldSave); } - public function tearDown() : void + public function tearDown(): void { if (file_exists($this->tmpFile)) { unlink($this->tmpFile); diff --git a/test/UserStateTest.php b/test/UserStateTest.php index f600e314..7d6e2acd 100644 --- a/test/UserStateTest.php +++ b/test/UserStateTest.php @@ -12,15 +12,15 @@ */ class UserStateTest extends TestCase { - public function testWithNoCurrentExercisesOrCompleted() : void + public function testWithNoCurrentExercisesOrCompleted(): void { - $state = new UserState; + $state = new UserState(); $this->assertFalse($state->isAssignedExercise()); $this->assertEmpty($state->getCompletedExercises()); $this->assertNull($state->getCurrentExercise()); } - public function testWithCurrentExerciseButNoCompleted() : void + public function testWithCurrentExerciseButNoCompleted(): void { $state = new UserState([], 'exercise1'); $this->assertTrue($state->isAssignedExercise()); @@ -28,7 +28,7 @@ public function testWithCurrentExerciseButNoCompleted() : void $this->assertSame('exercise1', $state->getCurrentExercise()); } - public function testWithCurrentExerciseAndCompleted() : void + public function testWithCurrentExerciseAndCompleted(): void { $state = new UserState(['exercise1'], 'exercise2'); $this->assertTrue($state->isAssignedExercise()); @@ -36,7 +36,7 @@ public function testWithCurrentExerciseAndCompleted() : void $this->assertSame('exercise2', $state->getCurrentExercise()); } - public function testWithCompletedExerciseButNoCurrent() : void + public function testWithCompletedExerciseButNoCurrent(): void { $state = new UserState(['exercise1']); $this->assertFalse($state->isAssignedExercise()); @@ -44,7 +44,7 @@ public function testWithCompletedExerciseButNoCurrent() : void $this->assertNull($state->getCurrentExercise()); } - public function testAddCompletedExercise() : void + public function testAddCompletedExercise(): void { $state = new UserState([], 'exercise1'); $this->assertTrue($state->isAssignedExercise()); @@ -57,7 +57,7 @@ public function testAddCompletedExercise() : void $this->assertSame('exercise1', $state->getCurrentExercise()); } - public function testSetCompletedExercise() : void + public function testSetCompletedExercise(): void { $state = new UserState(['exercise1']); $this->assertFalse($state->isAssignedExercise()); @@ -70,7 +70,7 @@ public function testSetCompletedExercise() : void $this->assertSame(['exercise1'], $state->getCompletedExercises()); } - public function testCompletedExercise() : void + public function testCompletedExercise(): void { $state = new UserState(['exercise1']); $this->assertTrue($state->completedExercise('exercise1')); diff --git a/test/Util/ArrayObjectTest.php b/test/Util/ArrayObjectTest.php index 43d04a55..d316a626 100644 --- a/test/Util/ArrayObjectTest.php +++ b/test/Util/ArrayObjectTest.php @@ -12,7 +12,7 @@ */ class ArrayObjectTest extends TestCase { - public function testMap() : void + public function testMap(): void { $arrayObject = new ArrayObject([1, 2, 3]); $new = $arrayObject->map(function ($elem) { @@ -23,13 +23,13 @@ public function testMap() : void $this->assertEquals([2, 4, 6], $new->getArrayCopy()); } - public function testImplode() : void + public function testImplode(): void { $arrayObject = new ArrayObject([1, 2, 3]); $this->assertSame('1 2 3', $arrayObject->implode(' ')); } - public function testPrepend() : void + public function testPrepend(): void { $arrayObject = new ArrayObject([1, 2, 3]); $new = $arrayObject->prepend(0); @@ -38,7 +38,7 @@ public function testPrepend() : void $this->assertSame([0, 1, 2, 3], $new->getArrayCopy()); } - public function testAppend() : void + public function testAppend(): void { $arrayObject = new ArrayObject([1, 2, 3]); $new = $arrayObject->append(4); @@ -47,19 +47,19 @@ public function testAppend() : void $this->assertSame([1, 2, 3, 4], $new->getArrayCopy()); } - public function testGetIterator() : void + public function testGetIterator(): void { $arrayObject = new ArrayObject([1, 2, 3]); $this->assertSame([1, 2, 3], iterator_to_array($arrayObject)); } - public function testGetArrayCopy() : void + public function testGetArrayCopy(): void { $arrayObject = new ArrayObject([1, 2, 3]); $this->assertSame([1, 2, 3], $arrayObject->getArrayCopy()); } - public function testFlatMap() : void + public function testFlatMap(): void { $arrayObject = new ArrayObject([ ['name' => 'Aydin', 'pets' => ['rat', 'raccoon', 'binturong']], @@ -72,7 +72,7 @@ public function testFlatMap() : void $this->assertSame(['rat', 'raccoon', 'binturong', 'rabbit', 'squirrel', 'dog'], $new->getArrayCopy()); } - public function testCollapse() : void + public function testCollapse(): void { $arrayObject = new ArrayObject([[1, 2], [3, 4, 5], [6, 7, 8]]); $new = $arrayObject->collapse(); @@ -86,7 +86,7 @@ public function testCollapse() : void $this->assertSame([1, 2, 3, 4, 5, 6, 7, 8], $new->getArrayCopy()); } - public function testReduce() : void + public function testReduce(): void { $arrayObject = new ArrayObject([6, 3, 1]); $total = $arrayObject->reduce(function ($carry, $item) { @@ -96,7 +96,7 @@ public function testReduce() : void $this->assertEquals(10, $total); } - public function testKeys() : void + public function testKeys(): void { $arrayObject = new ArrayObject(['one' => 1, 'two' => 2, 'three' => 3]); $new = $arrayObject->keys(); @@ -104,19 +104,19 @@ public function testKeys() : void $this->assertSame(['one', 'two', 'three'], $new->getArrayCopy()); } - public function testGetReturnsDefaultIfNotSet() : void + public function testGetReturnsDefaultIfNotSet(): void { $arrayObject = new ArrayObject(['one' => 1, 'two' => 2, 'three' => 3]); $this->assertEquals(4, $arrayObject->get('four', 4)); } - public function testGet() : void + public function testGet(): void { $arrayObject = new ArrayObject(['one' => 1, 'two' => 2, 'three' => 3]); $this->assertEquals(3, $arrayObject->get('three')); } - public function testSet() : void + public function testSet(): void { $arrayObject = new ArrayObject([1, 2, 3]); $new = $arrayObject->set(3, 4); @@ -131,12 +131,12 @@ public function testSet() : void $this->assertSame(['one' => 1, 'two' => 2, 'three' => 4], $new->getArrayCopy()); } - public function testIsEmpty() : void + public function testIsEmpty(): void { $arrayObject = new ArrayObject([1, 2, 3]); self::assertFalse($arrayObject->isEmpty()); - $arrayObject = new ArrayObject; + $arrayObject = new ArrayObject(); self::assertTrue($arrayObject->isEmpty()); } } diff --git a/test/Util/RequestRendererTest.php b/test/Util/RequestRendererTest.php index 3c6928e4..c50a27fa 100644 --- a/test/Util/RequestRendererTest.php +++ b/test/Util/RequestRendererTest.php @@ -11,7 +11,7 @@ */ class RequestRendererTest extends TestCase { - public function testWriteRequestWithHeaders() : void + public function testWriteRequestWithHeaders(): void { $request = (new Request('http://www.time.com/api/pt?iso=2016-01-21T18:14:33+0000')) ->withMethod('GET'); @@ -20,10 +20,10 @@ public function testWriteRequestWithHeaders() : void $expected .= "METHOD: GET\n"; $expected .= "HEADERS: Host: www.time.com\n"; - $this->assertEquals($expected, (new RequestRenderer)->renderRequest($request)); + $this->assertEquals($expected, (new RequestRenderer())->renderRequest($request)); } - public function testWriteRequestWithNoHeaders() : void + public function testWriteRequestWithNoHeaders(): void { $request = (new Request('/endpoint')) ->withMethod('GET'); @@ -31,10 +31,10 @@ public function testWriteRequestWithNoHeaders() : void $expected = "URL: /endpoint\n"; $expected .= "METHOD: GET\n"; - $this->assertEquals($expected, (new RequestRenderer)->renderRequest($request)); + $this->assertEquals($expected, (new RequestRenderer())->renderRequest($request)); } - public function testWriteRequestWithPostBodyJson() : void + public function testWriteRequestWithPostBodyJson(): void { $request = (new Request('/endpoint')) ->withMethod('POST') @@ -52,10 +52,10 @@ public function testWriteRequestWithPostBodyJson() : void $expected .= " \"other_data\": \"test2\"\n"; $expected .= "}\n"; - $this->assertEquals($expected, (new RequestRenderer)->renderRequest($request)); + $this->assertEquals($expected, (new RequestRenderer())->renderRequest($request)); } - public function testWriteRequestWithPostBodyUrlEncoded() : void + public function testWriteRequestWithPostBodyUrlEncoded(): void { $request = (new Request('/endpoint')) ->withMethod('POST') @@ -70,6 +70,6 @@ public function testWriteRequestWithPostBodyUrlEncoded() : void $expected .= "HEADERS: Content-Type: application/x-www-form-urlencoded\n"; $expected .= "BODY: data=test&other_data=test2\n"; - $this->assertEquals($expected, (new RequestRenderer)->renderRequest($request)); + $this->assertEquals($expected, (new RequestRenderer())->renderRequest($request)); } }