From 4d2f24649df7c5fdd854ddbf9ae0cff7a0f9e810 Mon Sep 17 00:00:00 2001 From: Aaron Gustavo Nieves Date: Thu, 25 Jun 2026 19:43:51 -0500 Subject: [PATCH] Add functional test for issue #130 (DI state across kernel reboots) --- composer.lock | 54 ++++++++++++------------ config/routes.php | 5 +++ config/services.php | 3 ++ src/Controller/ExternalApiController.php | 22 ++++++++++ src/Service/ExternalApiStub.php | 25 +++++++++++ tests/Functional/IssuesCest.php | 18 ++++++++ 6 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 src/Controller/ExternalApiController.php create mode 100644 src/Service/ExternalApiStub.php diff --git a/composer.lock b/composer.lock index b4d577b..26ad3ba 100644 --- a/composer.lock +++ b/composer.lock @@ -5980,12 +5980,12 @@ "source": { "type": "git", "url": "https://github.com/Codeception/module-symfony.git", - "reference": "7f0cd5d5ef89658ed1a56185bf33047477686fc5" + "reference": "bb77041e9b3f3adfb1b215b55b680297baf56b51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/module-symfony/zipball/7f0cd5d5ef89658ed1a56185bf33047477686fc5", - "reference": "7f0cd5d5ef89658ed1a56185bf33047477686fc5", + "url": "https://api.github.com/repos/Codeception/module-symfony/zipball/bb77041e9b3f3adfb1b215b55b680297baf56b51", + "reference": "bb77041e9b3f3adfb1b215b55b680297baf56b51", "shasum": "" }, "require": { @@ -6079,7 +6079,7 @@ "issues": "https://github.com/Codeception/module-symfony/issues", "source": "https://github.com/Codeception/module-symfony/tree/main" }, - "time": "2026-06-25T19:43:59+00:00" + "time": "2026-06-25T22:17:23+00:00" }, { "name": "codeception/stub", @@ -7025,16 +7025,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.95.10", + "version": "v3.95.11", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "93e1ab3e1f153024bd3ab23c8a349556063c6f17" + "reference": "35f98e1293283397824d7f349ce5afb8747c3cd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/93e1ab3e1f153024bd3ab23c8a349556063c6f17", - "reference": "93e1ab3e1f153024bd3ab23c8a349556063c6f17", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/35f98e1293283397824d7f349ce5afb8747c3cd5", + "reference": "35f98e1293283397824d7f349ce5afb8747c3cd5", "shasum": "" }, "require": { @@ -7068,7 +7068,7 @@ "require-dev": { "facile-it/paraunit": "^1.3.1 || ^2.11.0", "infection/infection": "^0.32.7", - "justinrainbow/json-schema": "^6.9.0", + "justinrainbow/json-schema": "^6.10.0", "keradus/cli-executor": "^2.3", "mikey179/vfsstream": "^1.6.12", "php-coveralls/php-coveralls": "^2.9.1", @@ -7118,7 +7118,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.95.10" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.95.11" }, "funding": [ { @@ -7126,7 +7126,7 @@ "type": "github" } ], - "time": "2026-06-19T14:45:22+00:00" + "time": "2026-06-25T14:17:04+00:00" }, { "name": "graham-campbell/result-type", @@ -9100,12 +9100,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "23afac1b181cebf9a272d9cb3423c6c39f3710d9" + "reference": "c5afdab923ee443a1aadcdd52543132e5d92db90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/23afac1b181cebf9a272d9cb3423c6c39f3710d9", - "reference": "23afac1b181cebf9a272d9cb3423c6c39f3710d9", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/c5afdab923ee443a1aadcdd52543132e5d92db90", + "reference": "c5afdab923ee443a1aadcdd52543132e5d92db90", "shasum": "" }, "conflict": { @@ -9239,7 +9239,7 @@ "commerceteam/commerce": ">=0.9.6,<0.9.9", "components/jquery": ">=1.0.3,<3.5", "composer/composer": "<2.2.28|>=2.3,<2.9.8", - "concrete5/concrete5": "<9.4.8", + "concrete5/concrete5": "<9.5.1", "concrete5/core": "<8.5.8|>=9,<9.1", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/comments-bundle": ">=2,<4.13.40|>=5.0.0.0-RC1-dev,<5.3.4", @@ -9384,10 +9384,10 @@ "feehi/feehicms": "<=2.1.1", "fenom/fenom": "<=2.12.1", "filament/actions": ">=3.2,<3.2.123|>=4,<=4.11.3|>=5,<=5.6.3", - "filament/filament": ">=4,<4.3.1", + "filament/filament": ">=3,<=3.3.51|>=4,<4.11.5|>=5,<5.6.5", "filament/forms": ">=3,<=3.3.52", - "filament/infolists": ">=3,<3.2.115", - "filament/tables": ">=3,<=3.3.50|>=4,<4.8.5|>=5,<5.3.5", + "filament/infolists": ">=3,<3.2.115|>=4,<=4.11.4|>=5,<=5.6.4", + "filament/tables": ">=3,<=3.3.50|>=4,<=4.11.4|>=5,<=5.6.4", "filegator/filegator": "<7.8", "filp/whoops": "<2.1.13", "fineuploader/php-traditional-server": "<=1.2.2", @@ -9740,7 +9740,7 @@ "phpmailer/phpmailer": "<6.5", "phpmussel/phpmussel": ">=1,<1.6", "phpmyadmin/phpmyadmin": "<5.2.2", - "phpmyfaq/phpmyfaq": "<4.1.3", + "phpmyfaq/phpmyfaq": "<4.1.4", "phpoffice/common": "<0.2.9", "phpoffice/math": "<=0.2", "phpoffice/phpexcel": "<=1.8.2", @@ -9848,10 +9848,10 @@ "silverstripe-australia/advancedreports": ">=1,<=2", "silverstripe/admin": "<1.13.19|>=2,<2.1.8", "silverstripe/assets": "<2.4.5|>=3,<3.1.3", - "silverstripe/cms": "<4.11.3", + "silverstripe/cms": "<6.2.1", "silverstripe/comments": ">=1.3,<3.1.1", "silverstripe/forum": "<0.6.2|>=0.7,<0.7.4", - "silverstripe/framework": "<5.3.23", + "silverstripe/framework": "<6.2.2", "silverstripe/graphql": ">=2,<2.0.5|>=3,<3.8.2|>=4,<4.3.7|>=5,<5.1.3", "silverstripe/hybridsessions": ">=1,<2.4.1|>=2.5,<2.5.1", "silverstripe/recipe-cms": ">=4.5,<4.5.3", @@ -9861,7 +9861,8 @@ "silverstripe/silverstripe-omnipay": "<2.5.2|>=3,<3.0.2|>=3.1,<3.1.4|>=3.2,<3.2.1", "silverstripe/subsites": ">=2,<2.6.1", "silverstripe/taxonomy": ">=1.3,<1.3.1|>=2,<2.0.1", - "silverstripe/userforms": "<3|>=5,<5.4.2", + "silverstripe/userforms": "<6.4.9|>=7,<7.0.7|>=7.1,<7.1.1", + "silverstripe/versioned": "<3.2.1", "silverstripe/versioned-admin": ">=1,<1.11.1", "simogeo/filemanager": "<=2.5", "simple-updates/phpwhois": "<=1", @@ -9880,10 +9881,10 @@ "sjbr/sr-freecap": "<2.4.6|>=2.5,<2.5.3", "sjbr/static-info-tables": "<2.3.1", "slim/psr7": "<1.4.1|>=1.5,<1.5.1|>=1.6,<1.6.1", - "slim/slim": "<2.6", + "slim/slim": "<2.6|>=4.4,<=4.15.1", "slub/slub-events": "<3.0.3", "smarty/smarty": "<4.5.3|>=5,<5.1.1", - "snipe/snipe-it": "<8.4.1", + "snipe/snipe-it": "<=8.6.1", "socalnick/scn-social-auth": "<1.15.2", "socialiteproviders/steam": "<1.1", "solspace/craft-freeform": "<4.1.29|>=5,<=5.14.6", @@ -9923,6 +9924,7 @@ "sylius/paypal-plugin": "<1.6.2|>=1.7,<1.7.2|>=2,<2.0.2", "sylius/resource-bundle": ">=1,<1.3.14|>=1.4,<1.4.7|>=1.5,<1.5.2|>=1.6,<1.6.4", "sylius/sylius": "<1.9.12|>=1.10,<1.10.16|>=1.11,<1.11.17|>=1.12,<=1.12.22|>=1.13,<=1.13.14|>=1.14,<=1.14.17|>=2,<=2.0.15|>=2.1,<=2.1.11|>=2.2,<=2.2.2", + "symbiote/silverstripe-advancedworkflow": "<6.4.5|>=7,<7.1.3|>=7.2,<7.2.1", "symbiote/silverstripe-multivaluefield": ">=3,<3.1", "symbiote/silverstripe-queuedjobs": ">=3,<3.0.2|>=3.1,<3.1.4|>=4,<4.0.7|>=4.1,<4.1.2|>=4.2,<4.2.4|>=4.3,<4.3.3|>=4.4,<4.4.3|>=4.5,<4.5.1|>=4.6,<4.6.4", "symbiote/silverstripe-seed": "<6.0.3", @@ -9990,7 +9992,7 @@ "thelia/thelia": ">=2.1,<2.1.3", "theonedemon/phpwhois": "<=4.2.5", "thinkcmf/thinkcmf": "<6.0.8", - "thorsten/phpmyfaq": "<4.1.3", + "thorsten/phpmyfaq": "<4.1.4", "tikiwiki/tiki-manager": "<=17.1", "timber/timber": ">=0.16.6,<1.23.1|>=1.24,<1.24.1|>=2,<2.1", "tinymce/tinymce": "<7.9.3|>=8,<8.5.1", @@ -10200,7 +10202,7 @@ "type": "tidelift" } ], - "time": "2026-06-22T21:03:44+00:00" + "time": "2026-06-25T18:49:05+00:00" }, { "name": "sebastian/cli-parser", diff --git a/config/routes.php b/config/routes.php index 0e941cd..84caaa5 100644 --- a/config/routes.php +++ b/config/routes.php @@ -5,6 +5,7 @@ use App\Controller\BrowserController; use App\Controller\DashboardController; use App\Controller\DomCrawlerController; +use App\Controller\ExternalApiController; use App\Controller\FormController; use App\Controller\HomeController; use App\Controller\HttpClientController; @@ -17,6 +18,10 @@ ->controller(HomeController::class) ->methods(['GET']); + $routes->add('app_external_api', '/external-api') + ->controller(ExternalApiController::class) + ->methods(['GET']); + $routes->add('app_login', '/login') ->controller([SecurityController::class, 'login']) ->methods(['GET', 'POST']); diff --git a/config/services.php b/config/services.php index 9002de4..503f3b6 100644 --- a/config/services.php +++ b/config/services.php @@ -59,4 +59,7 @@ 'entity' => User::class, 'lazy' => true, ]); + + $services->set(App\Service\ExternalApiStub::class) + ->public(); }; diff --git a/src/Controller/ExternalApiController.php b/src/Controller/ExternalApiController.php new file mode 100644 index 0000000..a60dbf9 --- /dev/null +++ b/src/Controller/ExternalApiController.php @@ -0,0 +1,22 @@ +externalApi->getResponse()); + } +} diff --git a/src/Service/ExternalApiStub.php b/src/Service/ExternalApiStub.php new file mode 100644 index 0000000..c47f522 --- /dev/null +++ b/src/Service/ExternalApiStub.php @@ -0,0 +1,25 @@ +response = $response; + } + + public function getResponse(): string + { + return $this->response; + } +} diff --git a/tests/Functional/IssuesCest.php b/tests/Functional/IssuesCest.php index 33eb176..8713369 100644 --- a/tests/Functional/IssuesCest.php +++ b/tests/Functional/IssuesCest.php @@ -9,6 +9,7 @@ use App\Doctrine\FlushCounterListener; use App\Doctrine\RequestStackListener; use App\Entity\User; +use App\Service\ExternalApiStub; use App\Tests\Support\FunctionalTester; use Doctrine\DBAL\Connection; use Symfony\Component\Mime\Message; @@ -132,4 +133,21 @@ public function ensureMessageObjectsCanBeFetched(FunctionalTester $I) $I->assertEmailHeaderSame('Subject', 'Text message'); $I->assertInstanceOf(Message::class, $I->grabLastSentEmail()); } + + /** + * @see https://github.com/Codeception/module-symfony/issues/130 + */ + public function keepConfiguredServiceStateAcrossKernelReboot(FunctionalTester $I) + { + $I->amOnPage('/external-api'); + $I->see(ExternalApiStub::REAL_RESPONSE); + + /** @var ExternalApiStub $externalApi */ + $externalApi = $I->grabService(ExternalApiStub::class); + $externalApi->setFakeResponse('Faked API response'); + $I->persistService(ExternalApiStub::class); + + $I->amOnPage('/external-api'); + $I->see('Faked API response'); + } }