Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/PHPUnit/AbstractBrowserTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@
// 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();

Check warning on line 39 in src/PHPUnit/AbstractBrowserTestCase.php

View workflow job for this annotation

GitHub Actions / Coverage & SonarQube

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ // 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(); + } }

Check warning on line 39 in src/PHPUnit/AbstractBrowserTestCase.php

View workflow job for this annotation

GitHub Actions / Coverage & SonarQube

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ // 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(); + } }
}
}
4 changes: 3 additions & 1 deletion src/PHPUnit/AbstractUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ protected function setUp(): void
{
parent::setUp();

Di::reset();
if ($this->phalconAvailable()) {
Di::reset();
}
}

public function checkExtensionIsLoaded(string $extension): void
Expand Down
1 change: 0 additions & 1 deletion tests/Fakes/Browser/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');
}

Expand Down
26 changes: 26 additions & 0 deletions tests/Unit/PHPUnit/AbstractUnitTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading