diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c14a4c..2746932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [0.7.0](https://github.com/phalcon/talon/releases/tag/v0.7.0) (2026-07-10) + +### Changed + +### Added + +### Fixed + +- `AbstractUnitTestCase::setUp()` now guards its `Di::reset()` call behind `phalconAvailable()`, so packages that use the Talon abstract test cases without Phalcon (or without the DI component) no longer hit a fatal `Class "Phalcon\Di\Di" not found` at setup time - because `AbstractUnitTestCase` is the root of the hierarchy, every abstract (`AbstractServicesTestCase`/`AbstractDatabaseTestCase`/`AbstractBrowserTestCase`/`AbstractFunctionalTestCase`) inherits the fix and can be extended without a DI. When Phalcon is available the reset still runs unchanged. [#14](https://github.com/phalcon/talon/issues/14) +- `AbstractBrowserTestCase` now clears `$_SESSION` in `tearDown()` as well as `setUp()`, so a test that logs a user in no longer leaks that session into a following test that does not reset it itself. The browser fixture session persists across the in-process app rebuilds and `Di::reset()` does not clear it, which surfaced as a random-order failure of `FixtureSmokeTest::testSecuredShowsGuestWithoutSession` (it read a `sarah` session left behind by `BrowserTraitTest`). [#16](https://github.com/phalcon/talon/pull/16) + +### Removed + ## [0.6.0](https://github.com/phalcon/talon/releases/tag/v0.6.0) (2026-07-02) ### Changed diff --git a/src/PHPUnit/AbstractBrowserTestCase.php b/src/PHPUnit/AbstractBrowserTestCase.php index 2fa94c9..2b9f0e3 100644 --- a/src/PHPUnit/AbstractBrowserTestCase.php +++ b/src/PHPUnit/AbstractBrowserTestCase.php @@ -29,4 +29,13 @@ protected function setUp(): void // session across requests within a test; clear it between tests). $_SESSION = []; } + + protected function tearDown(): void + { + // Clear on the way out too, so a logged-in session is not leaked into a + // following test that does not reset it itself. + $_SESSION = []; + + parent::tearDown(); + } } diff --git a/src/PHPUnit/AbstractUnitTestCase.php b/src/PHPUnit/AbstractUnitTestCase.php index c119735..852d67b 100644 --- a/src/PHPUnit/AbstractUnitTestCase.php +++ b/src/PHPUnit/AbstractUnitTestCase.php @@ -39,7 +39,9 @@ protected function setUp(): void { parent::setUp(); - Di::reset(); + if ($this->phalconAvailable()) { + Di::reset(); + } } public function checkExtensionIsLoaded(string $extension): void diff --git a/tests/Fakes/Browser/app.php b/tests/Fakes/Browser/app.php index 0d8fac5..10551a6 100644 --- a/tests/Fakes/Browser/app.php +++ b/tests/Fakes/Browser/app.php @@ -23,7 +23,6 @@ // session.* warns once a session has started. if (PHP_SESSION_NONE === session_status()) { ini_set('session.use_cookies', '0'); - ini_set('session.use_only_cookies', '0'); ini_set('session.cache_limiter', ''); } diff --git a/tests/Unit/PHPUnit/AbstractUnitTestCaseTest.php b/tests/Unit/PHPUnit/AbstractUnitTestCaseTest.php index 1d5e134..f2adad7 100644 --- a/tests/Unit/PHPUnit/AbstractUnitTestCaseTest.php +++ b/tests/Unit/PHPUnit/AbstractUnitTestCaseTest.php @@ -106,6 +106,32 @@ public function testSetUpResetsTheDefaultDi(): void $this->assertNull(Di::getDefault()); } + public function testSetUpSkipsDiResetWhenPhalconIsNotAvailable(): void + { + $default = new FactoryDefault(); + Di::setDefault($default); + + // A test case that reports Phalcon as unavailable must not touch the DI, + // so packages without Phalcon/DI can still use the Talon abstracts. + $withoutPhalcon = new class ('runSetUp') extends AbstractUnitTestCase { + public function runSetUp(): void + { + $this->setUp(); + } + + protected function phalconAvailable(): bool + { + return false; + } + }; + + $withoutPhalcon->runSetUp(); + + $this->assertSame($default, Di::getDefault()); + + Di::reset(); + } + public function testHelperMethodVisibility(): void { // Execute each helper so this test covers the mutated method bodies