Skip to content

Commit 147ce16

Browse files
authored
Always disable spatie/once cache during testing (#613)
* Always disable spatie/once cache during testing * Require the package for development
1 parent 08a66b0 commit 147ce16

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Changed
11+
12+
- Disable `spatie/once`'s cache if found during unit testing.
13+
1014
## v1.3.3 - 2025-01-10
1115

1216
### Added

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"phpstan/phpstan": "1.10.67",
5858
"phpunit/phpunit": "^9.3.3 || ^10.0.7 || ^11.0",
5959
"rector/rector": "^1.0",
60+
"spatie/once": "^3.1",
6061
"spatie/ray": "^1.41",
6162
"squizlabs/php_codesniffer": "^3.7",
6263
"symplify/monorepo-builder": "^10.3.3",

src/mantle/testing/class-test-case.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ abstract public function create_application(): Application;
9292
* Runs the routine before setting up all tests.
9393
*/
9494
public static function setUpBeforeClass(): void {
95+
parent::setUpBeforeClass();
96+
97+
// Disable the Spatie once cache for tests.
98+
if ( class_exists( \Spatie\Once\Once::class ) ) {
99+
\Spatie\Once\Cache::getInstance()->disable();
100+
}
101+
95102
static::register_traits();
96103

97104
if ( ! empty( static::$test_uses ) ) {

0 commit comments

Comments
 (0)