Skip to content

Commit

Permalink
Always disable spatie/once cache during testing (#613)
Browse files Browse the repository at this point in the history
* Always disable spatie/once cache during testing

* Require the package for development
  • Loading branch information
srtfisher authored Jan 14, 2025
1 parent 08a66b0 commit 147ce16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Disable `spatie/once`'s cache if found during unit testing.

## v1.3.3 - 2025-01-10

### Added
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"phpstan/phpstan": "1.10.67",
"phpunit/phpunit": "^9.3.3 || ^10.0.7 || ^11.0",
"rector/rector": "^1.0",
"spatie/once": "^3.1",
"spatie/ray": "^1.41",
"squizlabs/php_codesniffer": "^3.7",
"symplify/monorepo-builder": "^10.3.3",
Expand Down
7 changes: 7 additions & 0 deletions src/mantle/testing/class-test-case.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ abstract public function create_application(): Application;
* Runs the routine before setting up all tests.
*/
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();

// Disable the Spatie once cache for tests.
if ( class_exists( \Spatie\Once\Once::class ) ) {
\Spatie\Once\Cache::getInstance()->disable();
}

static::register_traits();

if ( ! empty( static::$test_uses ) ) {
Expand Down

0 comments on commit 147ce16

Please sign in to comment.