From d200dbb648b13a9652b6e03d8ca9d8d650122bbb Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 11 May 2024 10:34:52 +0200 Subject: [PATCH 1/8] Update PHP8 appreciate for new workshop version --- .docker/runtime/Dockerfile | 14 ++ .docker/runtime/docker-compose.yml | 14 ++ composer.json | 2 +- composer.lock | 137 +++++++++--------- src/Exercise/AMatchMadeInHeaven.php | 22 ++- src/Exercise/ASafeSpaceForNulls.php | 17 ++- src/Exercise/AllMixedUp.php | 24 +-- src/Exercise/CautionWithCatches.php | 22 ++- src/Exercise/HaveTheLastSay.php | 36 ++--- src/Exercise/InfiniteDivisions.php | 26 ++-- src/Exercise/LordOfTheStrings.php | 26 ++-- src/Exercise/PhpGetsAPromotion.php | 12 +- src/Exercise/StringifyToDemystify.php | 25 ++-- src/Exercise/TheAttributesOfSuccess.php | 50 ++++--- src/Exercise/TheReturnOfStatic.php | 16 +- src/Exercise/ThrowAnExpression.php | 22 +-- src/Exercise/UniteTheTypes.php | 14 +- test/Exercise/LordOfTheStringsTest.php | 2 +- .../lord-of-the-strings/solution-no-code.php | 1 - .../solution-no-composer.php | 3 + 20 files changed, 283 insertions(+), 202 deletions(-) create mode 100644 .docker/runtime/Dockerfile create mode 100644 .docker/runtime/docker-compose.yml delete mode 100644 test/solutions/lord-of-the-strings/solution-no-code.php create mode 100644 test/solutions/lord-of-the-strings/solution-no-composer.php diff --git a/.docker/runtime/Dockerfile b/.docker/runtime/Dockerfile new file mode 100644 index 0000000..dc8e93f --- /dev/null +++ b/.docker/runtime/Dockerfile @@ -0,0 +1,14 @@ +FROM php:8.3-alpine as build + +RUN apk add --no-cache $PHPIZE_DEPS && \ + apk add --no-cache linux-headers + +RUN docker-php-ext-install sockets + +FROM php:8.3-alpine as final + +COPY --from=build /usr/local/lib/php /usr/local/lib/php +COPY --from=build /usr/local/etc/php /usr/local/etc/php + +RUN apk add git +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \ No newline at end of file diff --git a/.docker/runtime/docker-compose.yml b/.docker/runtime/docker-compose.yml new file mode 100644 index 0000000..8ea2906 --- /dev/null +++ b/.docker/runtime/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + runtime: + image: php8appreciate-runtime + build: + context: . + dockerfile: Dockerfile + + volumes: + - type: bind + source: ${SOLUTION} + target: '/solution' + diff --git a/composer.json b/composer.json index 7c702d9..3b2d862 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ ], "require": { "php": "^8.0", - "php-school/php-workshop": "dev-master" + "php-school/php-workshop": "dev-05-09-remove_temporary_solution_mapper" }, "require-dev": { "phpunit/phpunit": "^9", diff --git a/composer.lock b/composer.lock index 5f88a06..5405d1b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "861a3809372ea7552bbd417ed292aff9", + "content-hash": "7bd3b34dc505a0982f14fe5cf1e61f63", "packages": [ { "name": "beberlei/assert", @@ -734,21 +734,21 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v4.19.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", @@ -784,9 +784,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-03-17T08:10:35+00:00" }, { "name": "php-di/invoker", @@ -1126,16 +1126,16 @@ }, { "name": "php-school/php-workshop", - "version": "dev-master", + "version": "dev-05-09-remove_temporary_solution_mapper", "source": { "type": "git", "url": "https://github.com/php-school/php-workshop.git", - "reference": "11911b2157e80480a8cc272b56f417f5ba4903bf" + "reference": "30483511ef91935c41dadc588edb5d6b548041c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/php-workshop/zipball/11911b2157e80480a8cc272b56f417f5ba4903bf", - "reference": "11911b2157e80480a8cc272b56f417f5ba4903bf", + "url": "https://api.github.com/repos/php-school/php-workshop/zipball/30483511ef91935c41dadc588edb5d6b548041c5", + "reference": "30483511ef91935c41dadc588edb5d6b548041c5", "shasum": "" }, "require": { @@ -1165,7 +1165,6 @@ "squizlabs/php_codesniffer": "^3.7", "yoast/phpunit-polyfills": "^0.2.0" }, - "default-branch": true, "type": "library", "autoload": { "files": [ @@ -1204,9 +1203,9 @@ ], "support": { "issues": "https://github.com/php-school/php-workshop/issues", - "source": "https://github.com/php-school/php-workshop/tree/master" + "source": "https://github.com/php-school/php-workshop/tree/05-09-remove_temporary_solution_mapper" }, - "time": "2024-03-10T13:04:10+00:00" + "time": "2024-05-11T08:45:34+00:00" }, { "name": "php-school/terminal", @@ -1367,20 +1366,20 @@ }, { "name": "psr/http-factory", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/php-fig/http-factory.git", - "reference": "e616d01114759c4c489f93b099585439f795fe35" + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", - "reference": "e616d01114759c4c489f93b099585439f795fe35", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", "shasum": "" }, "require": { - "php": ">=7.0.0", + "php": ">=7.1", "psr/http-message": "^1.0 || ^2.0" }, "type": "library", @@ -1404,7 +1403,7 @@ "homepage": "https://www.php-fig.org/" } ], - "description": "Common interfaces for PSR-7 HTTP message factories", + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", "keywords": [ "factory", "http", @@ -1416,9 +1415,9 @@ "response" ], "support": { - "source": "https://github.com/php-fig/http-factory/tree/1.0.2" + "source": "https://github.com/php-fig/http-factory" }, - "time": "2023-04-10T20:10:41+00:00" + "time": "2024-04-15T12:06:14+00:00" }, { "name": "psr/http-message", @@ -1569,16 +1568,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.4.0", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", "shasum": "" }, "require": { @@ -1587,7 +1586,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -1616,7 +1615,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" }, "funding": [ { @@ -1632,26 +1631,27 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/filesystem", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb" + "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", - "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/78dde75f8f6dbbca4ec436a4b0087f7af02076d4", + "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4", "shasum": "" }, "require": { "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8" + "symfony/polyfill-mbstring": "~1.8", + "symfony/process": "^5.4|^6.4" }, "type": "library", "autoload": { @@ -1679,7 +1679,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.3" + "source": "https://github.com/symfony/filesystem/tree/v6.4.7" }, "funding": [ { @@ -1695,7 +1695,7 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:51:35+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1858,16 +1858,16 @@ }, { "name": "symfony/process", - "version": "v6.4.4", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "710e27879e9be3395de2b98da3f52a946039f297" + "reference": "cdb1c81c145fd5aa9b0038bab694035020943381" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/710e27879e9be3395de2b98da3f52a946039f297", - "reference": "710e27879e9be3395de2b98da3f52a946039f297", + "url": "https://api.github.com/repos/symfony/process/zipball/cdb1c81c145fd5aa9b0038bab694035020943381", + "reference": "cdb1c81c145fd5aa9b0038bab694035020943381", "shasum": "" }, "require": { @@ -1899,7 +1899,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.4" + "source": "https://github.com/symfony/process/tree/v6.4.7" }, "funding": [ { @@ -1915,7 +1915,7 @@ "type": "tidelift" } ], - "time": "2024-02-20T12:31:00+00:00" + "time": "2024-04-18T09:22:46+00:00" } ], "packages-dev": [ @@ -2168,16 +2168,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.60", + "version": "1.10.67", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "95dcea7d6c628a3f2f56d091d8a0219485a86bbe" + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/95dcea7d6c628a3f2f56d091d8a0219485a86bbe", - "reference": "95dcea7d6c628a3f2f56d091d8a0219485a86bbe", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", "shasum": "" }, "require": { @@ -2220,13 +2220,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2024-03-07T13:30:19+00:00" + "time": "2024-04-16T07:22:02+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2549,16 +2545,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.17", + "version": "9.6.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd" + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1a156980d78a6666721b7e8e8502fe210b587fcd", - "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", "shasum": "" }, "require": { @@ -2632,7 +2628,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.17" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" }, "funding": [ { @@ -2648,7 +2644,7 @@ "type": "tidelift" } ], - "time": "2024-02-23T13:14:51+00:00" + "time": "2024-04-05T04:35:58+00:00" }, { "name": "sebastian/cli-parser", @@ -3452,16 +3448,16 @@ }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -3473,7 +3469,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -3494,8 +3490,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -3503,7 +3498,7 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", @@ -3616,16 +3611,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.0", + "version": "3.9.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", "shasum": "" }, "require": { @@ -3692,7 +3687,7 @@ "type": "open_collective" } ], - "time": "2024-02-16T15:06:51+00:00" + "time": "2024-04-23T20:25:34+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/Exercise/AMatchMadeInHeaven.php b/src/Exercise/AMatchMadeInHeaven.php index e8fc17c..b6f7473 100644 --- a/src/Exercise/AMatchMadeInHeaven.php +++ b/src/Exercise/AMatchMadeInHeaven.php @@ -9,14 +9,14 @@ use PhpParser\NodeVisitorAbstract; use PhpParser\Parser; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; -use PhpSchool\PhpWorkshop\Exercise\BaseExerciseTrait; use PhpSchool\PhpWorkshop\Exercise\CliExercise; -use PhpSchool\PhpWorkshop\Exercise\DefaultExercise; -use PhpSchool\PhpWorkshop\Exercise\ExerciseAssets; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; use PhpSchool\PhpWorkshop\Exercise\ProvidesInitialCode; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Result\Failure; use PhpSchool\PhpWorkshop\Result\ResultInterface; @@ -24,6 +24,8 @@ use PhpSchool\PhpWorkshop\Solution\SingleFileSolution; use PhpSchool\PhpWorkshop\Solution\SolutionInterface; +use function PhpSchool\PhpWorkshop\collect; + class AMatchMadeInHeaven extends AbstractExercise implements ExerciseInterface, CliExercise, @@ -44,8 +46,10 @@ public function getDescription(): string return 'PHP 8\'s Match Expression'; } - public function getArgs(): array + public function defineTestScenario(): CliScenario { + $environment = new CliScenario(); + $runs = [ ['enter'], ['esc'], @@ -55,7 +59,11 @@ public function getArgs(): array shuffle($runs); - return $runs; + foreach ($runs as $run) { + $environment->withExecution($run); + } + + return $environment; } public function getInitialCode(): SolutionInterface @@ -65,9 +73,9 @@ public function getInitialCode(): SolutionInterface ); } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); if (null === $statements || empty($statements)) { return Failure::fromNameAndReason($this->getName(), 'No code was found'); diff --git a/src/Exercise/ASafeSpaceForNulls.php b/src/Exercise/ASafeSpaceForNulls.php index e2b1434..d8887a8 100644 --- a/src/Exercise/ASafeSpaceForNulls.php +++ b/src/Exercise/ASafeSpaceForNulls.php @@ -17,15 +17,17 @@ use PhpParser\NodeFinder; use PhpParser\Parser; use PhpSchool\PhpWorkshop\Check\FileComparisonCheck; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\Exercise\SubmissionPatchable; use PhpSchool\PhpWorkshop\ExerciseCheck\FileComparisonExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; use PhpSchool\PhpWorkshop\ExerciseDispatcher; -use PhpSchool\PhpWorkshop\Input\Input; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Patch; use PhpSchool\PhpWorkshop\Result\Failure; use PhpSchool\PhpWorkshop\Result\ResultInterface; @@ -59,14 +61,15 @@ public function getType(): ExerciseType return new ExerciseType(ExerciseType::CLI); } - public function getArgs(): array + public function getRequiredChecks(): array { - return []; + return [FileComparisonCheck::class]; } - public function configure(ExerciseDispatcher $dispatcher): void + public function defineTestScenario(): CliScenario { - $dispatcher->requireCheck(FileComparisonCheck::class); + return (new CliScenario()) + ->withExecution(); } public function getPatch(): Patch @@ -171,10 +174,10 @@ public function getPatch(): Patch }); } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); $ageFetch = $this->findNullSafePropFetch($statements, 'user', 'age'); $addressFetch = $this->findAllNullSafePropertyFetch($statements, 'user', 'address'); diff --git a/src/Exercise/AllMixedUp.php b/src/Exercise/AllMixedUp.php index c4cd217..d1bcfe8 100644 --- a/src/Exercise/AllMixedUp.php +++ b/src/Exercise/AllMixedUp.php @@ -14,15 +14,20 @@ use PhpParser\Parser; use PhpSchool\PhpWorkshop\Check\FileComparisonCheck; use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\Exercise\SubmissionPatchable; use PhpSchool\PhpWorkshop\ExerciseCheck\FileComparisonExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\CliContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\RunnerContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Patch; use PhpSchool\PhpWorkshop\Result\Failure; @@ -58,15 +63,9 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function configure(ExerciseDispatcher $dispatcher): void + public function getRequiredChecks(): array { - $dispatcher->requireCheck(FunctionRequirementsCheck::class); - $dispatcher->requireCheck(FileComparisonCheck::class); - } - - public function getArgs(): array - { - return []; + return [FunctionRequirementsCheck::class, FileComparisonCheck::class]; } public function getPatch(): Patch @@ -134,10 +133,10 @@ public function getBannedFunctions(): array return []; } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); /** @var Function_|null $logger */ $logger = (new NodeFinder())->findFirst($statements, function (\PhpParser\Node $node) { @@ -170,4 +169,9 @@ public function check(Input $input): ResultInterface return new Success($this->getName()); } + + public function defineTestScenario(): CliScenario + { + return (new CliScenario())->withExecution(); + } } diff --git a/src/Exercise/CautionWithCatches.php b/src/Exercise/CautionWithCatches.php index 81efd45..ed1f8f0 100644 --- a/src/Exercise/CautionWithCatches.php +++ b/src/Exercise/CautionWithCatches.php @@ -10,12 +10,17 @@ use PhpParser\NodeFinder; use PhpParser\Parser; use PhpSchool\PhpWorkshop\CodeInsertion; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\Exercise\SubmissionPatchable; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\CliContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Patch; use PhpSchool\PhpWorkshop\Result\Failure; @@ -49,16 +54,10 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function getArgs(): array - { - $this->password = $this->faker->password(); - return [[$this->password]]; - } - - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); /** @var TryCatch|null $tryCatch */ $tryCatch = (new NodeFinder())->findFirstInstanceOf($statements, TryCatch::class); @@ -87,4 +86,11 @@ function verify_password(string \$password) { return (new Patch())->withInsertion($passwordVerifyInsertion); } + + public function defineTestScenario(): CliScenario + { + $this->password = $this->faker->password(); + + return (new CliScenario())->withExecution([$this->password]); + } } diff --git a/src/Exercise/HaveTheLastSay.php b/src/Exercise/HaveTheLastSay.php index 42b5b31..94a7c6d 100644 --- a/src/Exercise/HaveTheLastSay.php +++ b/src/Exercise/HaveTheLastSay.php @@ -8,13 +8,19 @@ use PhpParser\NodeFinder; use PhpParser\Parser; use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\Exercise\TemporaryDirectoryTrait; use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\CliContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\RunnerContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Result\Failure; use PhpSchool\PhpWorkshop\Result\FailureInterface; @@ -45,10 +51,8 @@ public function getDescription(): string return 'Use named arguments to specify the last to a specific parameter'; } - public function getArgs(): array + public function defineTestScenario(): CliScenario { - $file = $this->getTemporaryPath(); - $countries = [ ['UK', 'London'], ['Austria', 'Vienna'], @@ -62,14 +66,15 @@ public function getArgs(): array ['Belarus', 'Minsk'], ]; - file_put_contents( - $file, - collect($this->getRandomCountries($countries))->map(fn ($row) => implode("|", $row))->implode("\n") - ); + $fileContent = collect($this->getRandomCountries($countries)) + ->map(fn ($row) => implode("|", $row)) + ->implode("\n"); - return [ - [$file] - ]; + $fileName = sprintf('countries-%s.csv', bin2hex(random_bytes(4))); + + return (new CliScenario()) + ->withExecution(["./$fileName"]) + ->withFile($fileName, $fileContent); } /** @@ -84,11 +89,6 @@ private function getRandomCountries(array $countries): array ); } - public function tearDown(): void - { - unlink($this->getTemporaryPath()); - } - public function getType(): ExerciseType { return ExerciseType::CLI(); @@ -104,16 +104,16 @@ public function getBannedFunctions(): array return []; } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); if (null === $statements || empty($statements)) { return Failure::fromNameAndReason($this->getName(), 'No code was found'); } $check = new FunctionRequirementsCheck($this->parser); - $result = $check->check($this, $input); + $result = $check->check($context); if ($result instanceof FailureInterface) { return $result; diff --git a/src/Exercise/InfiniteDivisions.php b/src/Exercise/InfiniteDivisions.php index 454c0c4..e0a64d6 100644 --- a/src/Exercise/InfiniteDivisions.php +++ b/src/Exercise/InfiniteDivisions.php @@ -12,13 +12,17 @@ use PhpParser\NodeFinder; use PhpParser\Parser; use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\RunnerContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Result\Failure; use PhpSchool\PhpWorkshop\Result\ResultInterface; @@ -49,25 +53,25 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function configure(ExerciseDispatcher $dispatcher): void + public function getRequiredChecks(): array { - $dispatcher->requireCheck(FunctionRequirementsCheck::class); + return [FunctionRequirementsCheck::class]; } - public function getArgs(): array + public function defineTestScenario(): CliScenario { - return [ - [ + return (new CliScenario()) + ->withExecution([ (string) $this->faker->randomFloat(3, 10, 100), '0' - ], - [ + ]) + ->withExecution([ (string) $this->faker->randomFloat(3, 10, 100), (string) $this->faker->randomFloat(3, 0, 10) - ] - ]; + ]); } + public function getRequiredFunctions(): array { return ['fdiv', 'round']; @@ -78,10 +82,10 @@ public function getBannedFunctions(): array return []; } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); $finder = new NodeFinder(); diff --git a/src/Exercise/LordOfTheStrings.php b/src/Exercise/LordOfTheStrings.php index ea72642..1d70cd5 100644 --- a/src/Exercise/LordOfTheStrings.php +++ b/src/Exercise/LordOfTheStrings.php @@ -5,13 +5,17 @@ use Faker\Generator; use PhpSchool\PhpWorkshop\Check\ComposerCheck; use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\ExerciseCheck\ComposerExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\CliContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\RunnerContext; use PhpSchool\PhpWorkshop\Solution\DirectorySolution; use PhpSchool\PhpWorkshop\Solution\SolutionInterface; @@ -40,18 +44,12 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function configure(ExerciseDispatcher $dispatcher): void + public function getRequiredChecks(): array { - $dispatcher->requireCheck(FunctionRequirementsCheck::class); - $dispatcher->requireCheck(ComposerCheck::class); + return [FunctionRequirementsCheck::class, ComposerCheck::class]; } - public function getSolution(): SolutionInterface - { - return DirectorySolution::fromDirectory(__DIR__ . '/../../exercises/lord-of-the-strings/solution'); - } - - public function getArgs(): array + public function defineTestScenario(): CliScenario { /** @var string $word */ $word = $this->faker->words(1, true); @@ -67,9 +65,13 @@ public function getArgs(): array 'nowhere' => $sentence }; - return [ - [$word, $sentence] - ]; + return (new CliScenario()) + ->withExecution([$word, $sentence]); + } + + public function getSolution(): SolutionInterface + { + return DirectorySolution::fromDirectory(__DIR__ . '/../../exercises/lord-of-the-strings/solution'); } public function insertWordInSentenceRandomly(string $word, string $sentence): string diff --git a/src/Exercise/PhpGetsAPromotion.php b/src/Exercise/PhpGetsAPromotion.php index d269028..a1c7c69 100644 --- a/src/Exercise/PhpGetsAPromotion.php +++ b/src/Exercise/PhpGetsAPromotion.php @@ -13,7 +13,9 @@ use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; use PhpSchool\PhpWorkshop\Exercise\ProvidesInitialCode; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Result\Failure; use PhpSchool\PhpWorkshop\Result\ResultInterface; @@ -57,15 +59,15 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function getArgs(): array + public function defineTestScenario(): CliScenario { - return []; + return (new CliScenario())->withExecution(); } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); /** @var Class_|null $classNode */ $classNode = (new NodeFinder())->findFirstInstanceOf($statements, Class_::class); @@ -73,7 +75,7 @@ public function check(Input $input): ResultInterface return Failure::fromNameAndReason($this->getName(), 'No class was found'); } - (static fn () => require $input->getRequiredArgument('program'))(); + (static fn () => require $context->getEntryPoint())(); /** @var class-string $className */ $reflectionClass = new ReflectionClass($className); diff --git a/src/Exercise/StringifyToDemystify.php b/src/Exercise/StringifyToDemystify.php index bf84cf6..e419728 100644 --- a/src/Exercise/StringifyToDemystify.php +++ b/src/Exercise/StringifyToDemystify.php @@ -17,10 +17,12 @@ use PhpSchool\PhpWorkshop\Exercise\CgiExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CgiScenario; use PhpSchool\PhpWorkshop\Exercise\SubmissionPatchable; use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Patch; use PhpSchool\PhpWorkshop\Result\Failure; @@ -55,17 +57,16 @@ public function getType(): ExerciseType return ExerciseType::CGI(); } - public function configure(ExerciseDispatcher $dispatcher): void + public function getRequiredChecks(): array { - $dispatcher->requireCheck(FunctionRequirementsCheck::class); + return [FunctionRequirementsCheck::class]; } - /** - * @return array - */ - public function getRequests(): array + public function defineTestScenario(): CgiScenario { - return array_map( + $environment = new CgiScenario(); + + $requests = array_map( fn () => new Request( 'POST', 'https://phpschool.io/api', @@ -74,6 +75,12 @@ public function getRequests(): array ), array_fill(0, random_int(3, 6), null) ); + + foreach ($requests as $request) { + $environment->withExecution($request); + } + + return $environment; } /** @@ -132,10 +139,10 @@ public function getBannedFunctions(): array return []; } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var Stmt[] $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); /** @var Class_|null $classStmt */ $classStmt = (new NodeFinder())->findFirstInstanceOf($statements, Class_::class); diff --git a/src/Exercise/TheAttributesOfSuccess.php b/src/Exercise/TheAttributesOfSuccess.php index 934f4f7..fde0079 100644 --- a/src/Exercise/TheAttributesOfSuccess.php +++ b/src/Exercise/TheAttributesOfSuccess.php @@ -18,15 +18,18 @@ use PhpParser\Parser; use PhpSchool\PhpWorkshop\Check\FileComparisonCheck; use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; use PhpSchool\PhpWorkshop\Exercise\ProvidesInitialCode; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\ExerciseCheck\FileComparisonExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Result\Failure; use PhpSchool\PhpWorkshop\Result\ResultInterface; @@ -57,10 +60,29 @@ public function getDescription(): string return 'PHP 8\'s Attributes'; } - public function configure(ExerciseDispatcher $dispatcher): void + public function getRequiredChecks(): array { - $dispatcher->requireCheck(FileComparisonCheck::class); - $dispatcher->requireCheck(FunctionRequirementsCheck::class); + return [ + FileComparisonCheck::class, + FunctionRequirementsCheck::class + ]; + } + + public function defineTestScenario(): CliScenario + { + return (new CliScenario()) + ->withExecution([ + json_encode( + [ + 'id' => random_int(0, 100), + 'comment' => $this->faker->sentence(4), + 'rating' => $this->faker->numberBetween(0, 5), + 'reviewer' => $this->faker->userName(), + 'date' => $this->faker->date('d-m-Y') + ], + JSON_THROW_ON_ERROR + ) + ]); } public function getInitialCode(): SolutionInterface @@ -83,28 +105,10 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function getArgs(): array - { - return [ - [ - json_encode( - [ - 'id' => random_int(0, 100), - 'comment' => $this->faker->sentence(4), - 'rating' => $this->faker->numberBetween(0, 5), - 'reviewer' => $this->faker->userName(), - 'date' => $this->faker->date('d-m-Y') - ], - JSON_THROW_ON_ERROR - ) - ] - ]; - } - - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); /** @var Class_|null $classStmt */ $classStmt = (new NodeFinder())->findFirst($statements, function (Node $node) { diff --git a/src/Exercise/TheReturnOfStatic.php b/src/Exercise/TheReturnOfStatic.php index ab9d8b6..106fe61 100644 --- a/src/Exercise/TheReturnOfStatic.php +++ b/src/Exercise/TheReturnOfStatic.php @@ -12,12 +12,19 @@ use PhpParser\Node\Stmt\Function_; use PhpParser\NodeFinder; use PhpParser\Parser; +use PhpSchool\PhpWorkshop\Check\FileComparisonCheck; +use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; use PhpSchool\PhpWorkshop\Exercise\ProvidesInitialCode; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\CliContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Result\Failure; use PhpSchool\PhpWorkshop\Result\ResultInterface; @@ -57,15 +64,16 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function getArgs(): array + public function defineTestScenario(): CliScenario { - return []; + return (new CliScenario()) + ->withExecution([]); } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); $finder = new NodeFinder(); diff --git a/src/Exercise/ThrowAnExpression.php b/src/Exercise/ThrowAnExpression.php index 0848a21..7b0caa3 100644 --- a/src/Exercise/ThrowAnExpression.php +++ b/src/Exercise/ThrowAnExpression.php @@ -10,13 +10,16 @@ use PhpParser\Node\Stmt\If_; use PhpParser\NodeFinder; use PhpParser\Parser; +use PhpSchool\PhpWorkshop\Environment\CgiTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CgiExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; use PhpSchool\PhpWorkshop\Exercise\ProvidesInitialCode; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CgiScenario; use PhpSchool\PhpWorkshop\Exercise\SubmissionPatchable; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Patch; use PhpSchool\PhpWorkshop\Result\Failure; @@ -51,18 +54,10 @@ public function getType(): ExerciseType return ExerciseType::CGI(); } - public function getRequests(): array - { - return [ - (new Request('GET', 'https://top-secret.com/forbidden')), - (new Request('GET', 'https://top-secret.com/blog')) - ]; - } - - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); /** @var If_|null $if */ $if = (new NodeFinder())->findFirstInstanceOf($statements, If_::class); @@ -97,4 +92,11 @@ public function getPatch(): Patch return (new Patch()) ->withTransformer(new Patch\WrapInTryCatch(\InvalidArgumentException::class)); } + + public function defineTestScenario(): CgiScenario + { + return (new CgiScenario()) + ->withExecution(new Request('GET', 'https://top-secret.com/forbidden')) + ->withExecution(new Request('GET', 'https://top-secret.com/blog')); + } } diff --git a/src/Exercise/UniteTheTypes.php b/src/Exercise/UniteTheTypes.php index 0d7db46..beb1531 100644 --- a/src/Exercise/UniteTheTypes.php +++ b/src/Exercise/UniteTheTypes.php @@ -9,12 +9,17 @@ use PhpParser\NodeFinder; use PhpParser\Parser; use PhpSchool\PhpWorkshop\CodeInsertion; +use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseType; +use PhpSchool\PhpWorkshop\Exercise\Scenario\CliScenario; use PhpSchool\PhpWorkshop\Exercise\SubmissionPatchable; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; +use PhpSchool\PhpWorkshop\ExerciseDispatcher; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\CliContext; +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Input\Input; use PhpSchool\PhpWorkshop\Patch; use PhpSchool\PhpWorkshop\Result\Failure; @@ -47,7 +52,7 @@ public function getType(): ExerciseType return ExerciseType::CLI(); } - public function getArgs(): array + public function defineTestScenario(): CliScenario { $numbers = array_map( function (): string { @@ -59,7 +64,8 @@ function (): string { range(0, random_int(5, 15)) ); - return [$numbers]; + return (new CliScenario()) + ->withExecution($numbers); } public function getPatch(): Patch @@ -82,10 +88,10 @@ public function getPatch(): Patch ->withInsertion($casterInsertion); } - public function check(Input $input): ResultInterface + public function check(ExecutionContext $context): ResultInterface { /** @var array $statements */ - $statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program'))); + $statements = $this->parser->parse((string) file_get_contents($context->getEntryPoint())); /** @var Function_|null $adder */ $adder = (new NodeFinder())->findFirst($statements, function (\PhpParser\Node $node) { diff --git a/test/Exercise/LordOfTheStringsTest.php b/test/Exercise/LordOfTheStringsTest.php index e4d671c..2cc9f62 100644 --- a/test/Exercise/LordOfTheStringsTest.php +++ b/test/Exercise/LordOfTheStringsTest.php @@ -23,7 +23,7 @@ public function getExerciseClass(): string public function testWithNoComposerFile(): void { - $this->runExercise('solution-no-code.php'); + $this->runExercise('solution-no-composer.php'); $this->assertVerifyWasNotSuccessful(); $this->assertResultsHasFailureAndMatches(ComposerFailure::class, function (ComposerFailure $composerFailure) { diff --git a/test/solutions/lord-of-the-strings/solution-no-code.php b/test/solutions/lord-of-the-strings/solution-no-code.php deleted file mode 100644 index b3d9bbc..0000000 --- a/test/solutions/lord-of-the-strings/solution-no-code.php +++ /dev/null @@ -1 +0,0 @@ - Date: Fri, 17 May 2024 08:52:43 +0200 Subject: [PATCH 2/8] Update branch --- composer.json | 2 +- composer.lock | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 3b2d862..7c702d9 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ ], "require": { "php": "^8.0", - "php-school/php-workshop": "dev-05-09-remove_temporary_solution_mapper" + "php-school/php-workshop": "dev-master" }, "require-dev": { "phpunit/phpunit": "^9", diff --git a/composer.lock b/composer.lock index 5405d1b..052a41b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7bd3b34dc505a0982f14fe5cf1e61f63", + "content-hash": "861a3809372ea7552bbd417ed292aff9", "packages": [ { "name": "beberlei/assert", @@ -1126,16 +1126,16 @@ }, { "name": "php-school/php-workshop", - "version": "dev-05-09-remove_temporary_solution_mapper", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-school/php-workshop.git", - "reference": "30483511ef91935c41dadc588edb5d6b548041c5" + "reference": "ce202fb47f81c344c18b5ce7006a474ed7862702" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/php-workshop/zipball/30483511ef91935c41dadc588edb5d6b548041c5", - "reference": "30483511ef91935c41dadc588edb5d6b548041c5", + "url": "https://api.github.com/repos/php-school/php-workshop/zipball/ce202fb47f81c344c18b5ce7006a474ed7862702", + "reference": "ce202fb47f81c344c18b5ce7006a474ed7862702", "shasum": "" }, "require": { @@ -1158,14 +1158,21 @@ "symfony/process": "^4.0 | ^5.0 | ^6.0" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.8", "composer/composer": "^2.0", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.8", "phpunit/phpunit": "^8.5", - "squizlabs/php_codesniffer": "^3.7", "yoast/phpunit-polyfills": "^0.2.0" }, + "default-branch": true, "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "autoload": { "files": [ "src/Event/functions.php", @@ -1203,9 +1210,9 @@ ], "support": { "issues": "https://github.com/php-school/php-workshop/issues", - "source": "https://github.com/php-school/php-workshop/tree/05-09-remove_temporary_solution_mapper" + "source": "https://github.com/php-school/php-workshop/tree/master" }, - "time": "2024-05-11T08:45:34+00:00" + "time": "2024-05-17T19:12:46+00:00" }, { "name": "php-school/terminal", @@ -2168,16 +2175,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.67", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" + "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e524358f930e41a2b4cca1320e3b04fc26b39e0b", + "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b", "shasum": "" }, "require": { @@ -2222,7 +2229,7 @@ "type": "github" } ], - "time": "2024-04-16T07:22:02+00:00" + "time": "2024-05-15T08:00:59+00:00" }, { "name": "phpunit/php-code-coverage", From 2da5ce28c54497b6e36247952334d6f93b386068 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Fri, 17 May 2024 22:52:28 +0200 Subject: [PATCH 3/8] Run with docker process factory --- .docker/runtime/docker-compose.yml | 2 -- composer.json | 2 +- composer.lock | 15 +++++++-------- phpunit.xml | 3 +++ src/Exercise/ThrowAnExpression.php | 1 - test/Exercise/ThrowAnExpressionTest.php | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.docker/runtime/docker-compose.yml b/.docker/runtime/docker-compose.yml index 8ea2906..4d1bf84 100644 --- a/.docker/runtime/docker-compose.yml +++ b/.docker/runtime/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: runtime: image: php8appreciate-runtime diff --git a/composer.json b/composer.json index 7c702d9..5fd1fb9 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ ], "require": { "php": "^8.0", - "php-school/php-workshop": "dev-master" + "php-school/php-workshop": "dev-docker-fixes" }, "require-dev": { "phpunit/phpunit": "^9", diff --git a/composer.lock b/composer.lock index 052a41b..5594cd8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "861a3809372ea7552bbd417ed292aff9", + "content-hash": "eb93dbc5c18a5f711fbb75865235d490", "packages": [ { "name": "beberlei/assert", @@ -1126,16 +1126,16 @@ }, { "name": "php-school/php-workshop", - "version": "dev-master", + "version": "dev-configurable-process-factory", "source": { "type": "git", "url": "https://github.com/php-school/php-workshop.git", - "reference": "ce202fb47f81c344c18b5ce7006a474ed7862702" + "reference": "65049c5091e346413b645b04f408c953143747c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/php-workshop/zipball/ce202fb47f81c344c18b5ce7006a474ed7862702", - "reference": "ce202fb47f81c344c18b5ce7006a474ed7862702", + "url": "https://api.github.com/repos/php-school/php-workshop/zipball/65049c5091e346413b645b04f408c953143747c6", + "reference": "65049c5091e346413b645b04f408c953143747c6", "shasum": "" }, "require": { @@ -1165,7 +1165,6 @@ "phpunit/phpunit": "^8.5", "yoast/phpunit-polyfills": "^0.2.0" }, - "default-branch": true, "type": "library", "extra": { "bamarni-bin": { @@ -1210,9 +1209,9 @@ ], "support": { "issues": "https://github.com/php-school/php-workshop/issues", - "source": "https://github.com/php-school/php-workshop/tree/master" + "source": "https://github.com/php-school/php-workshop/tree/configurable-process-factory" }, - "time": "2024-05-17T19:12:46+00:00" + "time": "2024-05-17T19:27:26+00:00" }, { "name": "php-school/terminal", diff --git a/phpunit.xml b/phpunit.xml index 5200ada..dbf5daa 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,4 +9,7 @@ ./test ./test/solutions + + + diff --git a/src/Exercise/ThrowAnExpression.php b/src/Exercise/ThrowAnExpression.php index 7b0caa3..d5950ce 100644 --- a/src/Exercise/ThrowAnExpression.php +++ b/src/Exercise/ThrowAnExpression.php @@ -10,7 +10,6 @@ use PhpParser\Node\Stmt\If_; use PhpParser\NodeFinder; use PhpParser\Parser; -use PhpSchool\PhpWorkshop\Environment\CgiTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CgiExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; diff --git a/test/Exercise/ThrowAnExpressionTest.php b/test/Exercise/ThrowAnExpressionTest.php index 03d0666..efbd979 100644 --- a/test/Exercise/ThrowAnExpressionTest.php +++ b/test/Exercise/ThrowAnExpressionTest.php @@ -34,7 +34,7 @@ public function testThrowingWrongException(): void self::assertInstanceOf(Success::class, $output->getResults()[1]); self::assertMatchesRegularExpression( - '/Fatal error: Uncaught Exception: Access denied!/', + '/Fatal error: Uncaught Exception: Access denied!/', $output->getResults()[0]->getReason() ); From dac57b973c821ae5004f809b851a1b1db404b778 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Wed, 22 May 2024 22:58:06 +0200 Subject: [PATCH 4/8] Prime docker image --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b09072..35ce855 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,9 @@ jobs: - name: Install Dependencies run: composer update + - name: Build docker image + run: docker compose -p phpunit -f .docker/runtime/docker-compose.yml build + - name: Run phpunit tests run: | mkdir -p build/logs From 397bcbed0208f684d5b7152fbef891f1a6d16b28 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 25 May 2024 13:44:10 +0200 Subject: [PATCH 5/8] Try fix --- .docker/runtime/docker-compose.yml | 2 ++ .github/workflows/build.yml | 3 --- composer.lock | 34 +++++++++++++++--------------- src/Exercise/LordOfTheStrings.php | 3 --- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/.docker/runtime/docker-compose.yml b/.docker/runtime/docker-compose.yml index 4d1bf84..b38f58a 100644 --- a/.docker/runtime/docker-compose.yml +++ b/.docker/runtime/docker-compose.yml @@ -5,6 +5,8 @@ services: context: . dockerfile: Dockerfile + user: ${UID}:${GID} + volumes: - type: bind source: ${SOLUTION} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 35ce855..5b09072 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,9 +30,6 @@ jobs: - name: Install Dependencies run: composer update - - name: Build docker image - run: docker compose -p phpunit -f .docker/runtime/docker-compose.yml build - - name: Run phpunit tests run: | mkdir -p build/logs diff --git a/composer.lock b/composer.lock index 5594cd8..7dcc4b9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "eb93dbc5c18a5f711fbb75865235d490", + "content-hash": "2d8b0aef87879a02fc704a8f524de907", "packages": [ { "name": "beberlei/assert", @@ -1126,16 +1126,16 @@ }, { "name": "php-school/php-workshop", - "version": "dev-configurable-process-factory", + "version": "dev-docker-fixes", "source": { "type": "git", "url": "https://github.com/php-school/php-workshop.git", - "reference": "65049c5091e346413b645b04f408c953143747c6" + "reference": "86979bef6c82f5b835dc8a2906417a8c9d66b7c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/php-workshop/zipball/65049c5091e346413b645b04f408c953143747c6", - "reference": "65049c5091e346413b645b04f408c953143747c6", + "url": "https://api.github.com/repos/php-school/php-workshop/zipball/86979bef6c82f5b835dc8a2906417a8c9d66b7c3", + "reference": "86979bef6c82f5b835dc8a2906417a8c9d66b7c3", "shasum": "" }, "require": { @@ -1209,9 +1209,9 @@ ], "support": { "issues": "https://github.com/php-school/php-workshop/issues", - "source": "https://github.com/php-school/php-workshop/tree/configurable-process-factory" + "source": "https://github.com/php-school/php-workshop/tree/docker-fixes" }, - "time": "2024-05-17T19:27:26+00:00" + "time": "2024-05-25T12:02:59+00:00" }, { "name": "php-school/terminal", @@ -2174,16 +2174,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.1", + "version": "1.11.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b" + "reference": "0d5d4294a70deb7547db655c47685d680e39cfec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e524358f930e41a2b4cca1320e3b04fc26b39e0b", - "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d5d4294a70deb7547db655c47685d680e39cfec", + "reference": "0d5d4294a70deb7547db655c47685d680e39cfec", "shasum": "" }, "require": { @@ -2228,7 +2228,7 @@ "type": "github" } ], - "time": "2024-05-15T08:00:59+00:00" + "time": "2024-05-24T13:23:04+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3617,16 +3617,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.2", + "version": "3.10.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", - "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", "shasum": "" }, "require": { @@ -3693,7 +3693,7 @@ "type": "open_collective" } ], - "time": "2024-04-23T20:25:34+00:00" + "time": "2024-05-22T21:24:41+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/Exercise/LordOfTheStrings.php b/src/Exercise/LordOfTheStrings.php index 1d70cd5..a970347 100644 --- a/src/Exercise/LordOfTheStrings.php +++ b/src/Exercise/LordOfTheStrings.php @@ -5,7 +5,6 @@ use Faker\Generator; use PhpSchool\PhpWorkshop\Check\ComposerCheck; use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; -use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; @@ -14,8 +13,6 @@ use PhpSchool\PhpWorkshop\ExerciseCheck\ComposerExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\FunctionRequirementsExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseDispatcher; -use PhpSchool\PhpWorkshop\ExerciseRunner\Context\CliContext; -use PhpSchool\PhpWorkshop\ExerciseRunner\Context\RunnerContext; use PhpSchool\PhpWorkshop\Solution\DirectorySolution; use PhpSchool\PhpWorkshop\Solution\SolutionInterface; From 1dc4d4a1c7e14c4ec0686a9ea52238e696cbcfe2 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 25 May 2024 15:46:58 +0200 Subject: [PATCH 6/8] Remove unneccessary cleanup --- composer.lock | 8 ++--- src/Exercise/ASafeSpaceForNulls.php | 2 -- test/Exercise/ASafeSpaceForNullsTest.php | 38 +++++++++----------- test/Exercise/AllMixedUpTest.php | 6 ---- test/Exercise/LordOfTheStringsTest.php | 6 ++-- test/Exercise/TheAttributesOfSuccessTest.php | 36 +++++++++---------- 6 files changed, 42 insertions(+), 54 deletions(-) diff --git a/composer.lock b/composer.lock index 7dcc4b9..23a2645 100644 --- a/composer.lock +++ b/composer.lock @@ -1130,12 +1130,12 @@ "source": { "type": "git", "url": "https://github.com/php-school/php-workshop.git", - "reference": "86979bef6c82f5b835dc8a2906417a8c9d66b7c3" + "reference": "0790024a850786bfcbcefe7873da37bcc7b8e22d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/php-workshop/zipball/86979bef6c82f5b835dc8a2906417a8c9d66b7c3", - "reference": "86979bef6c82f5b835dc8a2906417a8c9d66b7c3", + "url": "https://api.github.com/repos/php-school/php-workshop/zipball/0790024a850786bfcbcefe7873da37bcc7b8e22d", + "reference": "0790024a850786bfcbcefe7873da37bcc7b8e22d", "shasum": "" }, "require": { @@ -1211,7 +1211,7 @@ "issues": "https://github.com/php-school/php-workshop/issues", "source": "https://github.com/php-school/php-workshop/tree/docker-fixes" }, - "time": "2024-05-25T12:02:59+00:00" + "time": "2024-05-25T13:44:46+00:00" }, { "name": "php-school/terminal", diff --git a/src/Exercise/ASafeSpaceForNulls.php b/src/Exercise/ASafeSpaceForNulls.php index d8887a8..117a66a 100644 --- a/src/Exercise/ASafeSpaceForNulls.php +++ b/src/Exercise/ASafeSpaceForNulls.php @@ -17,7 +17,6 @@ use PhpParser\NodeFinder; use PhpParser\Parser; use PhpSchool\PhpWorkshop\Check\FileComparisonCheck; -use PhpSchool\PhpWorkshop\Environment\CliTestEnvironment; use PhpSchool\PhpWorkshop\Exercise\AbstractExercise; use PhpSchool\PhpWorkshop\Exercise\CliExercise; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; @@ -26,7 +25,6 @@ use PhpSchool\PhpWorkshop\Exercise\SubmissionPatchable; use PhpSchool\PhpWorkshop\ExerciseCheck\FileComparisonExerciseCheck; use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck; -use PhpSchool\PhpWorkshop\ExerciseDispatcher; use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; use PhpSchool\PhpWorkshop\Patch; use PhpSchool\PhpWorkshop\Result\Failure; diff --git a/test/Exercise/ASafeSpaceForNullsTest.php b/test/Exercise/ASafeSpaceForNullsTest.php index 5a8aa4e..98023c5 100644 --- a/test/Exercise/ASafeSpaceForNullsTest.php +++ b/test/Exercise/ASafeSpaceForNullsTest.php @@ -20,11 +20,6 @@ public function getApplication(): Application return require __DIR__ . '/../../app/bootstrap.php'; } - public function tearDown(): void - { - $this->removeSolutionAsset('users.csv'); - } - public function testFailureWhenAgeAccessedWithoutNullSafe(): void { $this->runExercise('no-null-safe-age.php'); @@ -73,6 +68,23 @@ public function testFailureWhenAddressLine1AccessedWithoutNullSafe(): void ); } + + public function testFailureWhenCsvNotCorrect(): void + { + $this->runExercise('csv-wrong.php'); + + $this->assertVerifyWasNotSuccessful(); + + $this->assertResultsHasFailureAndMatches( + FileComparisonFailure::class, + function (FileComparisonFailure $failure) { + self::assertEquals('users.csv', $failure->getFileName()); + + return true; + } + ); + } + public function testFailureWhenAddressLine2AccessedWithoutNullSafe(): void { $this->runExercise('no-null-safe-address-line2.php'); @@ -97,22 +109,6 @@ public function testFailureWhenCsvNotExported(): void ); } - public function testFailureWhenCsvNotCorrect(): void - { - $this->runExercise('csv-wrong.php'); - - $this->assertVerifyWasNotSuccessful(); - - $this->assertResultsHasFailureAndMatches( - FileComparisonFailure::class, - function (FileComparisonFailure $failure) { - self::assertEquals('users.csv', $failure->getFileName()); - - return true; - } - ); - } - public function testWithCorrectSolution(): void { $this->runExercise('correct-solution.php'); diff --git a/test/Exercise/AllMixedUpTest.php b/test/Exercise/AllMixedUpTest.php index bc5f34c..8d8bad8 100644 --- a/test/Exercise/AllMixedUpTest.php +++ b/test/Exercise/AllMixedUpTest.php @@ -21,12 +21,6 @@ public function getApplication(): Application return require __DIR__ . '/../../app/bootstrap.php'; } - public function tearDown(): void - { - $this->removeSolutionAsset('param.log'); - parent::tearDown(); - } - public function testSuccessfulSolution(): void { $this->runExercise('solution-correct.php'); diff --git a/test/Exercise/LordOfTheStringsTest.php b/test/Exercise/LordOfTheStringsTest.php index 2cc9f62..60ce21e 100644 --- a/test/Exercise/LordOfTheStringsTest.php +++ b/test/Exercise/LordOfTheStringsTest.php @@ -36,7 +36,7 @@ public function testWithNoComposerFile(): void public function testWithNoCode(): void { - $this->runExercise('no-code/solution.php'); + $this->runExercise('no-code/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -45,7 +45,7 @@ public function testWithNoCode(): void public function testUsingBannedFunction(): void { - $this->runExercise('banned-functions/solution.php'); + $this->runExercise('banned-functions/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -73,7 +73,7 @@ function (FunctionRequirementsFailure $failure) { public function testWithCorrectSolution(): void { - $this->runExercise('correct-solution/solution.php'); + $this->runExercise('correct-solution/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasSuccessful(); } diff --git a/test/Exercise/TheAttributesOfSuccessTest.php b/test/Exercise/TheAttributesOfSuccessTest.php index 7e480d7..6c1e42a 100644 --- a/test/Exercise/TheAttributesOfSuccessTest.php +++ b/test/Exercise/TheAttributesOfSuccessTest.php @@ -24,7 +24,7 @@ public function getApplication(): Application public function testSuccessfulSolution(): void { - $this->runExercise('correct-solution/solution.php'); + $this->runExercise('correct-solution/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasSuccessful(); $this->assertOutputWasCorrect(); @@ -32,7 +32,7 @@ public function testSuccessfulSolution(): void public function testSuccessfulSolutionWithPromotedProperty(): void { - $this->runExercise('correct-solution-promoted/solution.php'); + $this->runExercise('correct-solution-promoted/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasSuccessful(); $this->assertOutputWasCorrect(); @@ -40,7 +40,7 @@ public function testSuccessfulSolutionWithPromotedProperty(): void public function testModifyingExternalCodeFails(): void { - $this->runExercise('modified-external-code/solution.php'); + $this->runExercise('modified-external-code/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); $this->assertOutputWasCorrect(); @@ -57,7 +57,7 @@ function (FileComparisonFailure $failure) { public function testNotCallingDeserializeFails(): void { - $this->runExercise('no-deserialize-call/solution.php'); + $this->runExercise('no-deserialize-call/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); $this->assertOutputWasIncorrect(); @@ -73,7 +73,7 @@ function (FunctionRequirementsFailure $failure) { public function testNotDumpingObjectFails(): void { - $this->runExercise('no-var-dump/solution.php'); + $this->runExercise('no-var-dump/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); $this->assertOutputWasIncorrect(); @@ -89,7 +89,7 @@ function (FunctionRequirementsFailure $failure) { public function testWhenOutputIsIncorrectComparisonFails(): void { - $this->runExercise('incorrect-output/solution.php'); + $this->runExercise('incorrect-output/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); $this->assertOutputWasIncorrect(); @@ -102,7 +102,7 @@ public function testWhenOutputIsIncorrectComparisonFails(): void public function testWhenNoClassNamedReviewDefined(): void { - $this->runExercise('no-review-class/solution.php'); + $this->runExercise('no-review-class/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -111,7 +111,7 @@ public function testWhenNoClassNamedReviewDefined(): void public function testWhenNoMethodNamedObfuscateReviewerDefined(): void { - $this->runExercise('no-obfuscate-method/solution.php'); + $this->runExercise('no-obfuscate-method/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -120,7 +120,7 @@ public function testWhenNoMethodNamedObfuscateReviewerDefined(): void public function testWhenNoAttributeDefinedOnObfuscateReviewerMethod(): void { - $this->runExercise('no-attributes/solution.php'); + $this->runExercise('no-attributes/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -129,7 +129,7 @@ public function testWhenNoAttributeDefinedOnObfuscateReviewerMethod(): void public function testWhenNoAttributedNamedObfuscateUsedOnMethod(): void { - $this->runExercise('no-attribute-named-obfuscate/solution.php'); + $this->runExercise('no-attribute-named-obfuscate/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -141,7 +141,7 @@ public function testWhenNoAttributedNamedObfuscateUsedOnMethod(): void public function testWhenNoArgumentsPassedToObfuscateAttribute(): void { - $this->runExercise('no-arguments-obfuscate-attribute/solution.php'); + $this->runExercise('no-arguments-obfuscate-attribute/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -153,7 +153,7 @@ public function testWhenNoArgumentsPassedToObfuscateAttribute(): void public function testWhenIncorrectPropertyPassedToObfuscateAttribute(): void { - $this->runExercise('invalid-arg-obfuscate-attribute/solution.php'); + $this->runExercise('invalid-arg-obfuscate-attribute/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -165,7 +165,7 @@ public function testWhenIncorrectPropertyPassedToObfuscateAttribute(): void public function testWhenObfuscateAttributeNotDefined(): void { - $this->runExercise('no-obfuscate-class/solution.php'); + $this->runExercise('no-obfuscate-class/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -174,7 +174,7 @@ public function testWhenObfuscateAttributeNotDefined(): void public function testWhenObfuscateHasNoAttributes(): void { - $this->runExercise('obfuscate-no-attributes/solution.php'); + $this->runExercise('obfuscate-no-attributes/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -183,7 +183,7 @@ public function testWhenObfuscateHasNoAttributes(): void public function testWhenObfuscateAttributeIncorrectlyDefined(): void { - $this->runExercise('obfuscate-attribute-incorrect/solution.php'); + $this->runExercise('obfuscate-attribute-incorrect/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -192,7 +192,7 @@ public function testWhenObfuscateAttributeIncorrectlyDefined(): void public function testWhenObfuscateAttributeHasNoFlags(): void { - $this->runExercise('obfuscate-attribute-no-flags/solution.php'); + $this->runExercise('obfuscate-attribute-no-flags/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -201,7 +201,7 @@ public function testWhenObfuscateAttributeHasNoFlags(): void public function testWhenObfuscateAttributeConfigurationIsWrong(): void { - $this->runExercise('obfuscate-attribute-wrong-target/solution.php'); + $this->runExercise('obfuscate-attribute-wrong-target/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); @@ -213,7 +213,7 @@ public function testWhenObfuscateAttributeConfigurationIsWrong(): void public function testWhenObfuscateAttributeHasNoPublicPropertyNamedKey(): void { - $this->runExercise('no-public-property-named-key/solution.php'); + $this->runExercise('no-public-property-named-key/solution.php', self::DIRECTORY_SOLUTION); $this->assertVerifyWasNotSuccessful(); From 8bcd69b7b09141e47da7c59cc03a73f08d06f58b Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 25 May 2024 16:01:13 +0200 Subject: [PATCH 7/8] Run tests with both host + docker --- .github/workflows/build.yml | 3 ++- composer.lock | 8 ++++---- phpunit.xml | 2 +- test/Exercise/ThrowAnExpressionTest.php | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b09072..d7a821d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,8 @@ jobs: - name: Run phpunit tests run: | mkdir -p build/logs - vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml + PROCESS_FACTORY=host vendor/bin/phpunit + PROCESS_FACTORY=docker vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml - name: Run phpcs run: composer cs diff --git a/composer.lock b/composer.lock index 23a2645..fdd73e7 100644 --- a/composer.lock +++ b/composer.lock @@ -1130,12 +1130,12 @@ "source": { "type": "git", "url": "https://github.com/php-school/php-workshop.git", - "reference": "0790024a850786bfcbcefe7873da37bcc7b8e22d" + "reference": "065947216d954289c70826afe27ccf0b6f49f109" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/php-workshop/zipball/0790024a850786bfcbcefe7873da37bcc7b8e22d", - "reference": "0790024a850786bfcbcefe7873da37bcc7b8e22d", + "url": "https://api.github.com/repos/php-school/php-workshop/zipball/065947216d954289c70826afe27ccf0b6f49f109", + "reference": "065947216d954289c70826afe27ccf0b6f49f109", "shasum": "" }, "require": { @@ -1211,7 +1211,7 @@ "issues": "https://github.com/php-school/php-workshop/issues", "source": "https://github.com/php-school/php-workshop/tree/docker-fixes" }, - "time": "2024-05-25T13:44:46+00:00" + "time": "2024-05-25T13:59:57+00:00" }, { "name": "php-school/terminal", diff --git a/phpunit.xml b/phpunit.xml index dbf5daa..eac0d7d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,6 +10,6 @@ ./test/solutions - + diff --git a/test/Exercise/ThrowAnExpressionTest.php b/test/Exercise/ThrowAnExpressionTest.php index efbd979..161748d 100644 --- a/test/Exercise/ThrowAnExpressionTest.php +++ b/test/Exercise/ThrowAnExpressionTest.php @@ -34,7 +34,7 @@ public function testThrowingWrongException(): void self::assertInstanceOf(Success::class, $output->getResults()[1]); self::assertMatchesRegularExpression( - '/Fatal error: Uncaught Exception: Access denied!/', + '/Fatal error:\s+Uncaught Exception: Access denied!/', $output->getResults()[0]->getReason() ); From 8f97aa207e94184605f12e855bbbd522b02fb44a Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Fri, 6 Sep 2024 21:27:38 +0200 Subject: [PATCH 8/8] Update deps --- composer.lock | 242 +++++++++++++++++++++++++------------------------- 1 file changed, 123 insertions(+), 119 deletions(-) diff --git a/composer.lock b/composer.lock index fdd73e7..695d33d 100644 --- a/composer.lock +++ b/composer.lock @@ -138,22 +138,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.8.1", + "version": "7.9.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "41042bc7ab002487b876a0683fc8dce04ddce104" + "reference": "d281ed313b989f213357e3be1a179f02196ac99b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104", - "reference": "41042bc7ab002487b876a0683fc8dce04ddce104", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0.1", - "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -164,9 +164,9 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", - "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "guzzle/client-integration-tests": "3.0.2", "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.36 || ^9.6.15", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -244,7 +244,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.8.1" + "source": "https://github.com/guzzle/guzzle/tree/7.9.2" }, "funding": [ { @@ -260,20 +260,20 @@ "type": "tidelift" } ], - "time": "2023-12-03T20:35:24+00:00" + "time": "2024-07-24T11:22:20+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223" + "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223", - "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223", + "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", "shasum": "" }, "require": { @@ -281,7 +281,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.36 || ^9.6.15" + "phpunit/phpunit": "^8.5.39 || ^9.6.20" }, "type": "library", "extra": { @@ -327,7 +327,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.2" + "source": "https://github.com/guzzle/promises/tree/2.0.3" }, "funding": [ { @@ -343,20 +343,20 @@ "type": "tidelift" } ], - "time": "2023-12-03T20:19:20+00:00" + "time": "2024-07-18T10:29:17+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.6.2", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201", "shasum": "" }, "require": { @@ -371,8 +371,8 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.36 || ^9.6.15" + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -443,7 +443,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.6.2" + "source": "https://github.com/guzzle/psr7/tree/2.7.0" }, "funding": [ { @@ -459,7 +459,7 @@ "type": "tidelift" } ], - "time": "2023-12-03T20:05:35+00:00" + "time": "2024-07-18T11:15:46+00:00" }, { "name": "kevinlebrun/colors.php", @@ -518,26 +518,27 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.3.3", + "version": "v1.3.4", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "3dbf8a8e914634c48d389c1234552666b3d43754" + "reference": "61b87392d986dc49ad5ef64e75b1ff5fee24ef81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/3dbf8a8e914634c48d389c1234552666b3d43754", - "reference": "3dbf8a8e914634c48d389c1234552666b3d43754", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/61b87392d986dc49ad5ef64e75b1ff5fee24ef81", + "reference": "61b87392d986dc49ad5ef64e75b1ff5fee24ef81", "shasum": "" }, "require": { "php": "^7.3|^8.0" }, "require-dev": { - "nesbot/carbon": "^2.61", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0", + "nesbot/carbon": "^2.61|^3.0", "pestphp/pest": "^1.21.3", "phpstan/phpstan": "^1.8.2", - "symfony/var-dumper": "^5.4.11" + "symfony/var-dumper": "^5.4.11|^6.2.0|^7.0.0" }, "type": "library", "extra": { @@ -574,7 +575,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2023-11-08T14:08:06+00:00" + "time": "2024-08-02T07:48:17+00:00" }, { "name": "league/commonmark", @@ -1130,12 +1131,12 @@ "source": { "type": "git", "url": "https://github.com/php-school/php-workshop.git", - "reference": "065947216d954289c70826afe27ccf0b6f49f109" + "reference": "73febf8c62d982cd74896df9266522dc2a5153b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/php-workshop/zipball/065947216d954289c70826afe27ccf0b6f49f109", - "reference": "065947216d954289c70826afe27ccf0b6f49f109", + "url": "https://api.github.com/repos/php-school/php-workshop/zipball/73febf8c62d982cd74896df9266522dc2a5153b5", + "reference": "73febf8c62d982cd74896df9266522dc2a5153b5", "shasum": "" }, "require": { @@ -1211,7 +1212,7 @@ "issues": "https://github.com/php-school/php-workshop/issues", "source": "https://github.com/php-school/php-workshop/tree/docker-fixes" }, - "time": "2024-05-25T13:59:57+00:00" + "time": "2024-09-04T11:22:50+00:00" }, { "name": "php-school/terminal", @@ -1641,23 +1642,25 @@ }, { "name": "symfony/filesystem", - "version": "v6.4.7", + "version": "v6.4.9", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4" + "reference": "b51ef8059159330b74a4d52f68e671033c0fe463" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/78dde75f8f6dbbca4ec436a4b0087f7af02076d4", - "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/b51ef8059159330b74a4d52f68e671033c0fe463", + "reference": "b51ef8059159330b74a4d52f68e671033c0fe463", "shasum": "" }, "require": { "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/process": "^5.4|^6.4" + "symfony/polyfill-mbstring": "~1.8" + }, + "require-dev": { + "symfony/process": "^5.4|^6.4|^7.0" }, "type": "library", "autoload": { @@ -1685,7 +1688,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.7" + "source": "https://github.com/symfony/filesystem/tree/v6.4.9" }, "funding": [ { @@ -1701,20 +1704,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-06-28T09:49:33+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -1764,7 +1767,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -1780,20 +1783,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -1844,7 +1847,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -1860,20 +1863,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/process", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "cdb1c81c145fd5aa9b0038bab694035020943381" + "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/cdb1c81c145fd5aa9b0038bab694035020943381", - "reference": "cdb1c81c145fd5aa9b0038bab694035020943381", + "url": "https://api.github.com/repos/symfony/process/zipball/8d92dd79149f29e89ee0f480254db595f6a6a2c5", + "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5", "shasum": "" }, "require": { @@ -1905,7 +1908,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.7" + "source": "https://github.com/symfony/process/tree/v6.4.8" }, "funding": [ { @@ -1921,7 +1924,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" } ], "packages-dev": [ @@ -1997,16 +2000,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -2014,11 +2017,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -2044,7 +2048,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -2052,7 +2056,7 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "phar-io/manifest", @@ -2174,16 +2178,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.2", + "version": "1.12.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "0d5d4294a70deb7547db655c47685d680e39cfec" + "reference": "0ca1c7bb55fca8fe6448f16fff0f311ccec960a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d5d4294a70deb7547db655c47685d680e39cfec", - "reference": "0d5d4294a70deb7547db655c47685d680e39cfec", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0ca1c7bb55fca8fe6448f16fff0f311ccec960a1", + "reference": "0ca1c7bb55fca8fe6448f16fff0f311ccec960a1", "shasum": "" }, "require": { @@ -2228,39 +2232,39 @@ "type": "github" } ], - "time": "2024-05-24T13:23:04+00:00" + "time": "2024-09-05T16:09:28+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.31", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -2269,7 +2273,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -2298,7 +2302,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -2306,7 +2310,7 @@ "type": "github" } ], - "time": "2024-03-02T06:37:42+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2551,45 +2555,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.19", + "version": "9.6.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" + "reference": "49d7820565836236411f5dc002d16dd689cde42f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/49d7820565836236411f5dc002d16dd689cde42f", + "reference": "49d7820565836236411f5dc002d16dd689cde42f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.31", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -2634,7 +2638,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.20" }, "funding": [ { @@ -2650,7 +2654,7 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:35:58+00:00" + "time": "2024-07-10T11:45:39+00:00" }, { "name": "sebastian/cli-parser", @@ -3617,16 +3621,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.1", + "version": "3.10.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" + "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", - "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017", + "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017", "shasum": "" }, "require": { @@ -3693,7 +3697,7 @@ "type": "open_collective" } ], - "time": "2024-05-22T21:24:41+00:00" + "time": "2024-07-21T23:26:44+00:00" }, { "name": "theseer/tokenizer",