From 50247c64fce25fabc584d4ba9391027c88491ad6 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 24 Oct 2020 19:50:43 +0100 Subject: [PATCH] CS Fixes --- CHANGELOG.md | 8 ++++++++ composer.json | 8 ++++++-- src/Application.php | 4 ++-- src/Check/CodeParseCheck.php | 2 +- src/Check/ComposerCheck.php | 6 +++--- src/CodePatcher.php | 8 ++++---- src/Command/CreditsCommand.php | 8 ++++---- src/Command/HelpCommand.php | 4 ++-- src/Command/VerifyCommand.php | 4 ++-- src/ComposerUtil/LockFileParser.php | 4 ++-- src/Result/Cgi/RequestFailure.php | 6 +++--- src/Result/Cli/RequestFailure.php | 2 +- src/Result/Failure.php | 2 +- src/Result/FunctionRequirementsFailure.php | 2 +- src/Result/ResultTrait.php | 2 +- src/Solution/DirectorySolution.php | 4 ++-- test/Check/CodeParseCheckTest.php | 6 +++--- test/Check/ComposerCheckTest.php | 2 +- test/Check/FunctionRequirementsCheckTest.php | 2 +- test/CodePatcherTest.php | 12 ++++++------ test/Command/CreditsCommandTest.php | 6 +++--- test/Command/MenuCommandInvokerTest.php | 2 +- test/Command/VerifyCommandTest.php | 8 ++++---- test/Exception/CodeExecutionExceptionTest.php | 2 +- test/Factory/MenuFactoryTest.php | 8 ++++---- test/Factory/ResultRendererFactoryTest.php | 4 ++-- test/MenuItem/ResetProgressTest.php | 2 +- test/PatchTest.php | 2 +- test/Result/Cgi/CgiResultTest.php | 4 ++-- test/Result/Cgi/RequestFailureTest.php | 8 ++++---- test/Result/Cli/CliResultTest.php | 2 +- test/Result/FailureTest.php | 2 +- test/Result/FunctionRequirementsFailureTest.php | 2 +- test/ResultAggregatorTest.php | 8 ++++---- test/Solution/DirectorySolutionTest.php | 12 ++++++------ test/Solution/SingleFileSolutionTest.php | 2 +- test/Solution/SolutionFileTest.php | 8 ++++---- 37 files changed, 95 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db3e1d18..734cbdbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,14 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip ### Removed +## [2.3.0] +### Added + - Builds support for PHP 7.4 + - Various code cleaning (phpstan, psr12, docblock removal) + +### Removed + - Removed support for PHP 7.1 + ## [2.2.0] ### Added - Builds for PHP 7.1 & 7.2 (#160) diff --git a/composer.json b/composer.json index 3b578b6c..5722c181 100644 --- a/composer.json +++ b/composer.json @@ -49,8 +49,8 @@ ] }, "autoload-dev": { - "psr-4": { - "PhpSchool\\PhpWorkshopTest\\": "test" + "psr-4": { + "PhpSchool\\PhpWorkshopTest\\": "test" } }, "scripts" : { @@ -58,6 +58,10 @@ "phpcs src --standard=PSR12 --encoding=UTF-8", "phpcs test --standard=PSR12 --encoding=UTF-8" ], + "cs-fix" : [ + "phpcbf src --standard=PSR12 --encoding=UTF-8", + "phpcbf test --standard=PSR12 --encoding=UTF-8" + ], "static": "phpstan --ansi analyse --level max src" } } diff --git a/src/Application.php b/src/Application.php index 352f4d4c..3d9bcdb6 100644 --- a/src/Application.php +++ b/src/Application.php @@ -72,7 +72,7 @@ public function __construct(string $workshopTitle, string $diConfigFile) { Assertion::string($workshopTitle); Assertion::file($diConfigFile); - + $this->workshopTitle = $workshopTitle; $this->diConfigFile = $diConfigFile; } @@ -159,7 +159,7 @@ public function setBgColour(string $colour): void public function run(): int { $container = $this->getContainer(); - + foreach ($this->exercises as $exercise) { if (false === $container->has($exercise)) { throw new \RuntimeException( diff --git a/src/Check/CodeParseCheck.php b/src/Check/CodeParseCheck.php index 02b95bfe..69368914 100644 --- a/src/Check/CodeParseCheck.php +++ b/src/Check/CodeParseCheck.php @@ -58,7 +58,7 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac } catch (Error $e) { return Failure::fromCheckAndCodeParseFailure($this, $e, $input->getRequiredArgument('program')); } - + return Success::fromCheck($this); } diff --git a/src/Check/ComposerCheck.php b/src/Check/ComposerCheck.php index a2ba915f..e724c938 100644 --- a/src/Check/ComposerCheck.php +++ b/src/Check/ComposerCheck.php @@ -40,7 +40,7 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac if (!$exercise instanceof ComposerExerciseCheck) { throw new \InvalidArgumentException(); } - + if (!file_exists(sprintf('%s/composer.json', dirname($input->getRequiredArgument('program'))))) { return new Failure($this->getName(), 'No composer.json file found'); } @@ -52,12 +52,12 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac if (!file_exists(sprintf('%s/vendor', dirname($input->getRequiredArgument('program'))))) { return new Failure($this->getName(), 'No vendor folder found'); } - + $lockFile = new LockFileParser(sprintf('%s/composer.lock', dirname($input->getRequiredArgument('program')))); $missingPackages = array_filter($exercise->getRequiredPackages(), function ($package) use ($lockFile) { return !$lockFile->hasInstalledPackage($package); }); - + if (count($missingPackages) > 0) { return new Failure( $this->getName(), diff --git a/src/CodePatcher.php b/src/CodePatcher.php index 6a38671f..80274c6d 100644 --- a/src/CodePatcher.php +++ b/src/CodePatcher.php @@ -20,12 +20,12 @@ class CodePatcher * @var Parser */ private $parser; - + /** * @var Standard */ private $printer; - + /** * @var Patch|null */ @@ -49,7 +49,7 @@ public function __construct(Parser $parser, Standard $printer, Patch $defaultPat $this->printer = $printer; $this->defaultPatch = $defaultPatch; } - + /** * Accepts an exercise and a string containing the students solution to the exercise. * @@ -71,7 +71,7 @@ public function patch(ExerciseInterface $exercise, string $code): string if ($exercise instanceof SubmissionPatchable) { $code = $this->applyPatch($exercise->getPatch(), $code); } - + return $code; } diff --git a/src/Command/CreditsCommand.php b/src/Command/CreditsCommand.php index 182a1805..3f37656d 100644 --- a/src/Command/CreditsCommand.php +++ b/src/Command/CreditsCommand.php @@ -14,7 +14,7 @@ class CreditsCommand * @var OutputInterface */ private $output; - + /** * @var Color */ @@ -61,7 +61,7 @@ private function writeContributors(array $contributors): void $this->output->writeLine(sprintf("%s %s", str_pad($name, (int) $nameColumnSize), $gitHubUser)); } } - + /** * * @return void @@ -71,7 +71,7 @@ public function __invoke(): void if (empty($this->coreContributors)) { return; } - + $this->output->writeLine( $this->color->__invoke("PHP School is bought to you by...")->yellow()->__toString() ); @@ -84,7 +84,7 @@ public function __invoke(): void $this->output->emptyLine(); $this->output->emptyLine(); - + $this->output->writeLine( $this->color->__invoke("This workshop is brought to you by...")->yellow()->__toString() ); diff --git a/src/Command/HelpCommand.php b/src/Command/HelpCommand.php index 18469c2b..646c30e4 100644 --- a/src/Command/HelpCommand.php +++ b/src/Command/HelpCommand.php @@ -15,7 +15,7 @@ class HelpCommand * @var string */ private $appName; - + /** * @var OutputInterface */ @@ -37,7 +37,7 @@ public function __construct($appName, OutputInterface $output, Color $color) $this->color = $color; $this->appName = $appName; } - + /** * @return void */ diff --git a/src/Command/VerifyCommand.php b/src/Command/VerifyCommand.php index 9ab483ea..e233de4c 100644 --- a/src/Command/VerifyCommand.php +++ b/src/Command/VerifyCommand.php @@ -35,7 +35,7 @@ class VerifyCommand * @var UserStateSerializer */ private $userStateSerializer; - + /** * @var ResultsRenderer */ @@ -84,7 +84,7 @@ public function __invoke(Input $input) $this->userState->addCompletedExercise($exercise->getName()); $this->userStateSerializer->serialize($this->userState); } - + $this->resultsRenderer->render($results, $exercise, $this->userState, $this->output); return $results->isSuccessful() ? 0 : 1; } diff --git a/src/ComposerUtil/LockFileParser.php b/src/ComposerUtil/LockFileParser.php index 6620c0ce..f89ef82d 100644 --- a/src/ComposerUtil/LockFileParser.php +++ b/src/ComposerUtil/LockFileParser.php @@ -23,7 +23,7 @@ public function __construct(string $lockFilePath) if (!file_exists($lockFilePath)) { throw new InvalidArgumentException(sprintf('Lock File: "%s" does not exist', $lockFilePath)); } - + $this->contents = json_decode((string) file_get_contents($lockFilePath), true); if (!isset($this->contents['packages'])) { @@ -66,7 +66,7 @@ public function hasInstalledPackage($packageName): bool return true; } } - + return false; } } diff --git a/src/Result/Cgi/RequestFailure.php b/src/Result/Cgi/RequestFailure.php index 7777ad4f..65c4f1ce 100644 --- a/src/Result/Cgi/RequestFailure.php +++ b/src/Result/Cgi/RequestFailure.php @@ -14,7 +14,7 @@ class RequestFailure implements FailureInterface * @var RequestInterface */ private $request; - + /** * @var string */ @@ -24,12 +24,12 @@ class RequestFailure implements FailureInterface * @var string */ private $actualOutput; - + /** * @var array */ private $expectedHeaders; - + /** * @var array */ diff --git a/src/Result/Cli/RequestFailure.php b/src/Result/Cli/RequestFailure.php index 22db1fa4..312ca321 100644 --- a/src/Result/Cli/RequestFailure.php +++ b/src/Result/Cli/RequestFailure.php @@ -59,7 +59,7 @@ public function getArgs(): ArrayObject { return $this->args; } - + /** * Get the expected output. * diff --git a/src/Result/Failure.php b/src/Result/Failure.php index 88a9830d..d7f643ce 100644 --- a/src/Result/Failure.php +++ b/src/Result/Failure.php @@ -45,7 +45,7 @@ public static function fromNameAndReason(string $name, ?string $reason): self { return new self($name, $reason); } - + /** * Static constructor to create from an instance of `PhpSchool\PhpWorkshop\Check\CheckInterface`. * diff --git a/src/Result/FunctionRequirementsFailure.php b/src/Result/FunctionRequirementsFailure.php index 2ed33dfd..80a5d0b9 100644 --- a/src/Result/FunctionRequirementsFailure.php +++ b/src/Result/FunctionRequirementsFailure.php @@ -11,7 +11,7 @@ class FunctionRequirementsFailure implements FailureInterface { use ResultTrait; - + /** * @var array */ diff --git a/src/Result/ResultTrait.php b/src/Result/ResultTrait.php index ef2de98d..4c565d07 100644 --- a/src/Result/ResultTrait.php +++ b/src/Result/ResultTrait.php @@ -14,7 +14,7 @@ trait ResultTrait * @var CheckInterface */ private $check; - + /** * Get the check name from the underlying check. Assumes that the `check` property has been * assigned an instance of `PhpSchool\PhpWorkshop\Check\CheckInterface`. diff --git a/src/Solution/DirectorySolution.php b/src/Solution/DirectorySolution.php index bdfdb052..3e49dc2f 100644 --- a/src/Solution/DirectorySolution.php +++ b/src/Solution/DirectorySolution.php @@ -63,11 +63,11 @@ public function __construct(string $directory, string $entryPoint, array $exclus sprintf('Entry point: "%s" does not exist in: "%s"', $entryPoint, $directory) ); } - + $this->files = array_map(function ($file) use ($directory) { return new SolutionFile($file, $directory); }, $files); - + $this->entryPoint = sprintf('%s/%s', $directory, $entryPoint); $this->baseDirectory = $directory; } diff --git a/test/Check/CodeParseCheckTest.php b/test/Check/CodeParseCheckTest.php index 4c7e79e8..3d5703c3 100644 --- a/test/Check/CodeParseCheckTest.php +++ b/test/Check/CodeParseCheckTest.php @@ -23,7 +23,7 @@ class CodeParseCheckTest extends TestCase * @var string */ private $file; - + public function setUp(): void { $this->check = new CodeParseCheck((new ParserFactory())->create(ParserFactory::PREFER_PHP7)); @@ -42,13 +42,13 @@ public function setUp(): void public function testUnParseableCodeReturnsFailure(): void { file_put_contents($this->file, 'check->check( $this->createMock(ExerciseInterface::class), new Input('app', ['program' => $this->file]) ); $this->assertInstanceOf(Failure::class, $result); - + $this->assertEquals('Code Parse Check', $result->getCheckName()); $this->assertMatchesRegularExpression( sprintf('|^File: "%s" could not be parsed\. Error: "|', preg_quote($this->file)), diff --git a/test/Check/ComposerCheckTest.php b/test/Check/ComposerCheckTest.php index b9657146..a8a0e985 100644 --- a/test/Check/ComposerCheckTest.php +++ b/test/Check/ComposerCheckTest.php @@ -37,7 +37,7 @@ public function setUp(): void $this->assertTrue($this->check->canRun(ExerciseType::CGI())); $this->assertTrue($this->check->canRun(ExerciseType::CLI())); } - + public function testExceptionIsThrownIfNotValidExercise(): void { $exercise = $this->createMock(ExerciseInterface::class); diff --git a/test/Check/FunctionRequirementsCheckTest.php b/test/Check/FunctionRequirementsCheckTest.php index 4c719965..70a10249 100644 --- a/test/Check/FunctionRequirementsCheckTest.php +++ b/test/Check/FunctionRequirementsCheckTest.php @@ -95,7 +95,7 @@ public function testFailureIsReturnedIfNotAllRequiredFunctionsHaveBeenUsed(): vo new Input('app', ['program' => __DIR__ . '/../res/function-requirements/fail-banned-function.php']) ); $this->assertInstanceOf(FunctionRequirementsFailure::class, $failure); - + $this->assertEquals(['file_get_contents', 'implode'], $failure->getMissingFunctions()); $this->assertEquals([], $failure->getBannedFunctions()); } diff --git a/test/CodePatcherTest.php b/test/CodePatcherTest.php index 53ff1778..312c95de 100644 --- a/test/CodePatcherTest.php +++ b/test/CodePatcherTest.php @@ -28,8 +28,8 @@ public function testDefaultPatchIsAppliedIfAvailable(): void $expected = "assertEquals($expected, $patcher->patch($exercise, 'create(ParserFactory::PREFER_PHP7), new Standard()); @@ -38,21 +38,21 @@ public function testPatcherDoesNotApplyPatchIfNotPatchableExercise(): void $code = 'assertEquals($code, $patcher->patch($exercise, $code)); } - + /** * @dataProvider codeProvider */ public function testPatcher(string $code, Patch $patch, string $expectedResult): void { $patcher = new CodePatcher((new ParserFactory())->create(ParserFactory::PREFER_PHP7), new Standard()); - + $exercise = $this->createMock(PatchableExercise::class); - + $exercise ->expects($this->once()) ->method('getPatch') ->willReturn($patch); - + $result = $patcher->patch($exercise, $code); $this->assertEquals($expectedResult, $result); } diff --git a/test/Command/CreditsCommandTest.php b/test/Command/CreditsCommandTest.php index 2c16f126..3be6fe22 100644 --- a/test/Command/CreditsCommandTest.php +++ b/test/Command/CreditsCommandTest.php @@ -60,17 +60,17 @@ public function testWithOnlyCoreContributors(): void public function testWithNoContributors(): void { $this->expectOutputString(''); - + $color = new Color(); $color->setForceStyle(true); - + $command = new CreditsCommand( [], [], new StdOutput($color, $this->createMock(Terminal::class)), $color ); - + $command->__invoke(); } } diff --git a/test/Command/MenuCommandInvokerTest.php b/test/Command/MenuCommandInvokerTest.php index be1a920c..4150c0bc 100644 --- a/test/Command/MenuCommandInvokerTest.php +++ b/test/Command/MenuCommandInvokerTest.php @@ -14,7 +14,7 @@ public function testInvoker(): void $menu ->expects($this->once()) ->method('close'); - + $command = $this->getMockBuilder('stdClass') ->setMethods(['__invoke']) ->getMock(); diff --git a/test/Command/VerifyCommandTest.php b/test/Command/VerifyCommandTest.php index 7e691f78..ba1e074e 100644 --- a/test/Command/VerifyCommandTest.php +++ b/test/Command/VerifyCommandTest.php @@ -25,7 +25,7 @@ class VerifyCommandTest extends TestCase * @var CheckInterface */ private $check; - + public function setUp(): void { $this->check = $this->createMock(CheckInterface::class); @@ -49,7 +49,7 @@ public function testVerifyAddsCompletedExerciseAndReturnsCorrectCodeOnSuccess(): $color = new Color(); $color->setForceStyle(true); $output = new StdOutput($color, $this->createMock(Terminal::class)); - + $serializer = $this->createMock(UserStateSerializer::class); $serializer ->expects($this->once()) @@ -68,13 +68,13 @@ public function testVerifyAddsCompletedExerciseAndReturnsCorrectCodeOnSuccess(): ->method('verify') ->with($exercise, $input) ->willReturn($results); - + $renderer ->expects($this->once()) ->method('render') ->with($results, $exercise, $state, $output); - + $command = new VerifyCommand($repo, $dispatcher, $state, $serializer, $output, $renderer); $this->assertEquals(0, $command->__invoke($input)); $this->assertEquals(['my-exercise'], $state->getCompletedExercises()); diff --git a/test/Exception/CodeExecutionExceptionTest.php b/test/Exception/CodeExecutionExceptionTest.php index 56b87932..f774c481 100644 --- a/test/Exception/CodeExecutionExceptionTest.php +++ b/test/Exception/CodeExecutionExceptionTest.php @@ -22,7 +22,7 @@ public function testFromProcessUsesErrorOutputIfNotEmpty(): void ->expects($this->once()) ->method('getErrorOutput') ->willReturn('Error Output'); - + $e = CodeExecutionException::fromProcess($process); $this->assertEquals('PHP Code failed to execute. Error: "Error Output"', $e->getMessage()); } diff --git a/test/Factory/MenuFactoryTest.php b/test/Factory/MenuFactoryTest.php index 985eaefe..3c240e6b 100644 --- a/test/Factory/MenuFactoryTest.php +++ b/test/Factory/MenuFactoryTest.php @@ -43,7 +43,7 @@ public function testFactoryReturnsInstance(): void $terminal ->method('getWidth') ->willReturn(70); - + $services = [ UserStateSerializer::class => $userStateSerializer, ExerciseRepository::class => $exerciseRepository, @@ -59,14 +59,14 @@ public function testFactoryReturnsInstance(): void EventDispatcher::class => $this->createMock(EventDispatcher::class), Terminal::class => $terminal ]; - + $container ->method('get') ->willReturnCallback(function ($name) use ($services) { return $services[$name]; }); - - + + $factory = new MenuFactory(); $this->assertInstanceOf(CliMenu::class, $factory($container)); } diff --git a/test/Factory/ResultRendererFactoryTest.php b/test/Factory/ResultRendererFactoryTest.php index 110dad9a..4b2c32e4 100644 --- a/test/Factory/ResultRendererFactoryTest.php +++ b/test/Factory/ResultRendererFactoryTest.php @@ -18,7 +18,7 @@ public function testRegisterRendererRequiresResultInterface(): void $resultClass = get_class($this->createMock(TestCase::class)); $rendererClass = get_class($this->createMock(ResultRendererInterface::class)); $factory = new ResultRendererFactory(); - + $factory->registerRenderer($resultClass, $rendererClass); } @@ -29,7 +29,7 @@ public function testRegisterRendererRequiresResultRendererInterface(): void $resultClass = get_class($this->createMock(ResultInterface::class)); $rendererClass = get_class($this->createMock(TestCase::class)); $factory = new ResultRendererFactory(); - + $factory->registerRenderer($resultClass, $rendererClass); } diff --git a/test/MenuItem/ResetProgressTest.php b/test/MenuItem/ResetProgressTest.php index c1bd909f..f6eb1caa 100644 --- a/test/MenuItem/ResetProgressTest.php +++ b/test/MenuItem/ResetProgressTest.php @@ -63,7 +63,7 @@ public function testResetProgressDisablesParentMenuItems(): void ->expects($this->once()) ->method('serialize') ->with($this->isInstanceOf(UserState::class)); - + $resetProgress = new ResetProgress($userStateSerializer); $resetProgress->__invoke($subMenu); } diff --git a/test/PatchTest.php b/test/PatchTest.php index da7aa634..29886afd 100644 --- a/test/PatchTest.php +++ b/test/PatchTest.php @@ -13,7 +13,7 @@ public function testWithInsertion(): void $patch = new Patch(); $insertion = new CodeInsertion(CodeInsertion::TYPE_BEFORE, 'MEH'); $new = $patch->withInsertion($insertion); - + $this->assertNotSame($patch, $new); $this->assertEmpty($patch->getModifiers()); $this->assertEquals([$insertion], $new->getModifiers()); diff --git a/test/Result/Cgi/CgiResultTest.php b/test/Result/Cgi/CgiResultTest.php index e49905c7..6cf038a5 100644 --- a/test/Result/Cgi/CgiResultTest.php +++ b/test/Result/Cgi/CgiResultTest.php @@ -21,12 +21,12 @@ public function testIsSuccessful(): void { $request = new RequestFailure($this->createMock(RequestInterface::class), '', '', [], []); $cgiResult = new CgiResult([$request]); - + $this->assertFalse($cgiResult->isSuccessful()); $cgiResult = new CgiResult([new Success($this->createMock(RequestInterface::class))]); $this->assertTrue($cgiResult->isSuccessful()); - + $cgiResult->add($request); $this->assertFalse($cgiResult->isSuccessful()); } diff --git a/test/Result/Cgi/RequestFailureTest.php b/test/Result/Cgi/RequestFailureTest.php index 6c0ac4af..d475021e 100644 --- a/test/Result/Cgi/RequestFailureTest.php +++ b/test/Result/Cgi/RequestFailureTest.php @@ -15,7 +15,7 @@ public function setUp(): void $this->assertSame('Request Failure', $requestFailure->getCheckName()); $this->assertSame($request, $requestFailure->getRequest()); } - + public function testWhenOnlyOutputDifferent(): void { $requestFailure = new RequestFailure( @@ -25,7 +25,7 @@ public function testWhenOnlyOutputDifferent(): void [], [] ); - + $this->assertEquals('Expected Output', $requestFailure->getExpectedOutput()); $this->assertEquals('Actual Output', $requestFailure->getActualOutput()); $this->assertTrue($requestFailure->bodyDifferent()); @@ -43,7 +43,7 @@ public function testWhenOnlyHeadersDifferent(): void ['header1' => 'some-value'], ['header2' => 'some-value'] ); - + $this->assertEquals(['header1' => 'some-value'], $requestFailure->getExpectedHeaders()); $this->assertEquals(['header2' => 'some-value'], $requestFailure->getActualHeaders()); $this->assertTrue($requestFailure->headersDifferent()); @@ -61,7 +61,7 @@ public function testWhenOutputAndHeadersDifferent(): void ['header1' => 'some-value'], ['header2' => 'some-value'] ); - + $this->assertTrue($requestFailure->headersDifferent()); $this->assertTrue($requestFailure->bodyDifferent()); $this->assertTrue($requestFailure->headersAndBodyDifferent()); diff --git a/test/Result/Cli/CliResultTest.php b/test/Result/Cli/CliResultTest.php index 83cbfc68..e37cd681 100644 --- a/test/Result/Cli/CliResultTest.php +++ b/test/Result/Cli/CliResultTest.php @@ -21,7 +21,7 @@ public function testIsSuccessful(): void { $request = new RequestFailure(new ArrayObject(), 'EXPECTED', 'ACTUAL'); $cliResult = new CliResult([$request]); - + $this->assertFalse($cliResult->isSuccessful()); $cliResult = new CliResult([new Success(new ArrayObject())]); diff --git a/test/Result/FailureTest.php b/test/Result/FailureTest.php index c407e129..262425c8 100644 --- a/test/Result/FailureTest.php +++ b/test/Result/FailureTest.php @@ -26,7 +26,7 @@ public function setUp(): void $failure = new Failure($this->check->getName(), ''); $this->assertSame('Some Check', $failure->getCheckName()); } - + public function testFailure(): void { $failure = new Failure($this->check->getName(), 'Something went wrong yo'); diff --git a/test/Result/FunctionRequirementsFailureTest.php b/test/Result/FunctionRequirementsFailureTest.php index 4dfb215c..23875513 100644 --- a/test/Result/FunctionRequirementsFailureTest.php +++ b/test/Result/FunctionRequirementsFailureTest.php @@ -14,7 +14,7 @@ public function testGetters(): void $check ->method('getName') ->willReturn('Some Check'); - + $failure = new FunctionRequirementsFailure($check, ['function' => 'file', 'line' => 3], ['explode']); $this->assertEquals(['function' => 'file', 'line' => 3], $failure->getBannedFunctions()); $this->assertEquals(['explode'], $failure->getMissingFunctions()); diff --git a/test/ResultAggregatorTest.php b/test/ResultAggregatorTest.php index 77eceff6..0d2a710a 100644 --- a/test/ResultAggregatorTest.php +++ b/test/ResultAggregatorTest.php @@ -26,7 +26,7 @@ public function setUp(): void ->method('getName') ->willReturn('Some Check'); } - + public function testIsSuccessful(): void { $resultAggregator = new ResultAggregator(); @@ -43,7 +43,7 @@ public function testIsSuccessfulWithResultGroups(): void { $resultAggregator = new ResultAggregator(); $this->assertTrue($resultAggregator->isSuccessful()); - + $resultGroup = new CliResult(); $resultGroup->add(new CliSuccess(new ArrayObject())); @@ -61,11 +61,11 @@ public function testIterator(): void new Success('Some Check'), new Failure('Some Check', 'nope') ]; - + $resultAggregator = new ResultAggregator(); $resultAggregator->add($results[0]); $resultAggregator->add($results[1]); - + $this->assertEquals($results, iterator_to_array($resultAggregator)); } } diff --git a/test/Solution/DirectorySolutionTest.php b/test/Solution/DirectorySolutionTest.php index 434e00f1..37b18356 100644 --- a/test/Solution/DirectorySolutionTest.php +++ b/test/Solution/DirectorySolutionTest.php @@ -13,10 +13,10 @@ public function testExceptionIsThrownIfEntryPointDoesNotExist(): void $tempPath = sprintf('%s/%s', realpath(sys_get_temp_dir()), $this->getName()); @mkdir($tempPath, 0775, true); touch(sprintf('%s/some-class.php', $tempPath)); - + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf('Entry point: "solution.php" does not exist in: "%s"', $tempPath)); - + DirectorySolution::fromDirectory($tempPath); unlink(sprintf('%s/some-class.php', $tempPath)); @@ -29,18 +29,18 @@ public function testWithDefaultEntryPoint(): void @mkdir($tempPath, 0775, true); touch(sprintf('%s/solution.php', $tempPath)); touch(sprintf('%s/some-class.php', $tempPath)); - + $solution = DirectorySolution::fromDirectory($tempPath); - + $this->assertSame($tempPath, $solution->getBaseDirectory()); $this->assertFalse($solution->hasComposerFile()); $this->assertSame(sprintf('%s/solution.php', $tempPath), $solution->getEntryPoint()); $files = $solution->getFiles(); $this->assertCount(2, $files); - + $this->assertSame(sprintf('%s/solution.php', $tempPath), $files[0]->__toString()); $this->assertSame(sprintf('%s/some-class.php', $tempPath), $files[1]->__toString()); - + unlink(sprintf('%s/solution.php', $tempPath)); unlink(sprintf('%s/some-class.php', $tempPath)); rmdir($tempPath); diff --git a/test/Solution/SingleFileSolutionTest.php b/test/Solution/SingleFileSolutionTest.php index e5241bc1..6fa336d7 100644 --- a/test/Solution/SingleFileSolutionTest.php +++ b/test/Solution/SingleFileSolutionTest.php @@ -16,7 +16,7 @@ public function testGetters(): void touch($filePath); $solution = SingleFileSolution::fromFile($filePath); - + $this->assertSame($filePath, $solution->getEntryPoint()); $this->assertSame($tempPath, $solution->getBaseDirectory()); $this->assertFalse($solution->hasComposerFile()); diff --git a/test/Solution/SolutionFileTest.php b/test/Solution/SolutionFileTest.php index 9423ca36..bdaee5d0 100644 --- a/test/Solution/SolutionFileTest.php +++ b/test/Solution/SolutionFileTest.php @@ -12,7 +12,7 @@ public function testExceptionIsThrowIfFileNotExists(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('File: "file/that/does/not/exist.php" does not exist'); - + SolutionFile::fromFile('file/that/does/not/exist.php'); } @@ -23,13 +23,13 @@ public function testPaths(): void @mkdir($tempPath, 0775, true); touch($filePath); - + $file = SolutionFile::fromFile($filePath); - + $this->assertSame($filePath, $file->__toString()); $this->assertSame('test.file', $file->getRelativePath()); $this->assertSame($tempPath, $file->getBaseDirectory()); - + unlink($filePath); rmdir($tempPath); }