From 468d1b4b0a731a2195cdcd5bde4a2c33e50f4df6 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 8 Apr 2026 16:35:05 +0100 Subject: [PATCH] backport #13674 --- src/Testing/AddonTestCase.php | 8 +++----- tests/FrontendTest.php | 4 +--- tests/Licensing/AddonLicenseTest.php | 2 -- tests/Licensing/LicenseManagerTest.php | 3 +-- tests/Markdown/ManagerTest.php | 1 - tests/TestCase.php | 8 +++----- 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/Testing/AddonTestCase.php b/src/Testing/AddonTestCase.php index 7d7d3faf185..7f463cff34e 100644 --- a/src/Testing/AddonTestCase.php +++ b/src/Testing/AddonTestCase.php @@ -32,12 +32,10 @@ protected function setUp(): void $this->preventSavingStacheItemsToDisk(); } - Version::shouldReceive('get')->zeroOrMoreTimes()->andReturn(Composer::create(__DIR__.'/../')->installedVersion(Statamic::PACKAGE)); - $this->addToAssertionCount(-1); + Version::shouldReceive('get')->andReturn(Composer::create(__DIR__.'/../')->installedVersion(Statamic::PACKAGE)); - \Statamic\Facades\CP\Nav::shouldReceive('build')->zeroOrMoreTimes()->andReturn(collect()); - \Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls')->zeroOrMoreTimes(); - $this->addToAssertionCount(-2); // Dont want to assert this + \Statamic\Facades\CP\Nav::shouldReceive('build')->andReturn(collect()); + \Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls'); } protected function tearDown(): void diff --git a/tests/FrontendTest.php b/tests/FrontendTest.php index fb5184b5b45..9e7d082a0cc 100644 --- a/tests/FrontendTest.php +++ b/tests/FrontendTest.php @@ -17,7 +17,6 @@ use Statamic\Facades\Blueprint; use Statamic\Facades\Cascade; use Statamic\Facades\Collection; -use Statamic\Facades\Entry; use Statamic\Facades\User; use Statamic\Tags\Tags; use Statamic\View\Antlers\Language\Utilities\StringUtilities; @@ -38,8 +37,7 @@ public function setUp(): void private function withStandardBlueprints() { - $this->addToAssertionCount(-1); - Blueprint::shouldReceive('in')->withAnyArgs()->zeroOrMoreTimes()->andReturn(collect([new \Statamic\Fields\Blueprint])); + Blueprint::shouldReceive('in')->withAnyArgs()->andReturn(collect([new \Statamic\Fields\Blueprint])); } #[Test] diff --git a/tests/Licensing/AddonLicenseTest.php b/tests/Licensing/AddonLicenseTest.php index e93e5dfce88..687b3584267 100644 --- a/tests/Licensing/AddonLicenseTest.php +++ b/tests/Licensing/AddonLicenseTest.php @@ -14,9 +14,7 @@ class AddonLicenseTest extends TestCase protected function license($response = []) { Addon::shouldReceive('get')->with('test/addon') - ->zeroOrMoreTimes() ->andReturn(new FakeAddonLicenseAddon('Test Addon', '1.2.3', 'rad')); - $this->addToAssertionCount(-1); // dont need to assert this. return new AddonLicense('test/addon', $response); } diff --git a/tests/Licensing/LicenseManagerTest.php b/tests/Licensing/LicenseManagerTest.php index 6138092b38a..44a37e27384 100644 --- a/tests/Licensing/LicenseManagerTest.php +++ b/tests/Licensing/LicenseManagerTest.php @@ -191,8 +191,7 @@ private function managerWithResponse(array $response) { $outpost = $this->mock(Outpost::class); - $this->addToAssertionCount(-1); // Dont want to assert this - $outpost->shouldReceive('response')->zeroOrMoreTimes()->andReturn($response); + $outpost->shouldReceive('response')->andReturn($response); return new LicenseManager($outpost); } diff --git a/tests/Markdown/ManagerTest.php b/tests/Markdown/ManagerTest.php index 2d74a75632d..ab9cd89c738 100644 --- a/tests/Markdown/ManagerTest.php +++ b/tests/Markdown/ManagerTest.php @@ -105,7 +105,6 @@ public function parser_instances_can_be_saved_and_retrieved() #[Test] public function it_throws_an_exception_if_extending_without_returning_a_parser() { - $this->expectNotToPerformAssertions(); $this->expectException(UnexpectedValueException::class); $this->expectExceptionMessage('A ['.Markdown\Parser::class.'] instance is expected.'); diff --git a/tests/TestCase.php b/tests/TestCase.php index c4b133de83f..8d9ba935f0e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,14 +32,12 @@ protected function setUp(): void } if ($this->shouldFakeVersion) { - \Facades\Statamic\Version::shouldReceive('get')->zeroOrMoreTimes()->andReturn('3.0.0-testing'); - $this->addToAssertionCount(-1); // Dont want to assert this + \Facades\Statamic\Version::shouldReceive('get')->andReturn('3.0.0-testing'); } if ($this->shouldPreventNavBeingBuilt) { - \Statamic\Facades\CP\Nav::shouldReceive('build')->zeroOrMoreTimes()->andReturn(collect()); - \Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls')->zeroOrMoreTimes(); - $this->addToAssertionCount(-2); // Dont want to assert this + \Statamic\Facades\CP\Nav::shouldReceive('build')->andReturn(collect()); + \Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls'); } $this->addGqlMacros();