Skip to content

Commit f3893f6

Browse files
[5.x] Remove negative assertions from TestCase (#14458)
1 parent 7b0694e commit f3893f6

File tree

6 files changed

+8
-18
lines changed

6 files changed

+8
-18
lines changed

src/Testing/AddonTestCase.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ protected function setUp(): void
3232
$this->preventSavingStacheItemsToDisk();
3333
}
3434

35-
Version::shouldReceive('get')->zeroOrMoreTimes()->andReturn(Composer::create(__DIR__.'/../')->installedVersion(Statamic::PACKAGE));
36-
$this->addToAssertionCount(-1);
35+
Version::shouldReceive('get')->andReturn(Composer::create(__DIR__.'/../')->installedVersion(Statamic::PACKAGE));
3736

38-
\Statamic\Facades\CP\Nav::shouldReceive('build')->zeroOrMoreTimes()->andReturn(collect());
39-
\Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls')->zeroOrMoreTimes();
40-
$this->addToAssertionCount(-2); // Dont want to assert this
37+
\Statamic\Facades\CP\Nav::shouldReceive('build')->andReturn(collect());
38+
\Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls');
4139
}
4240

4341
protected function tearDown(): void

tests/FrontendTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Statamic\Facades\Blueprint;
1818
use Statamic\Facades\Cascade;
1919
use Statamic\Facades\Collection;
20-
use Statamic\Facades\Entry;
2120
use Statamic\Facades\User;
2221
use Statamic\Tags\Tags;
2322
use Statamic\View\Antlers\Language\Utilities\StringUtilities;
@@ -38,8 +37,7 @@ public function setUp(): void
3837

3938
private function withStandardBlueprints()
4039
{
41-
$this->addToAssertionCount(-1);
42-
Blueprint::shouldReceive('in')->withAnyArgs()->zeroOrMoreTimes()->andReturn(collect([new \Statamic\Fields\Blueprint]));
40+
Blueprint::shouldReceive('in')->withAnyArgs()->andReturn(collect([new \Statamic\Fields\Blueprint]));
4341
}
4442

4543
#[Test]

tests/Licensing/AddonLicenseTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ class AddonLicenseTest extends TestCase
1414
protected function license($response = [])
1515
{
1616
Addon::shouldReceive('get')->with('test/addon')
17-
->zeroOrMoreTimes()
1817
->andReturn(new FakeAddonLicenseAddon('Test Addon', '1.2.3', 'rad'));
19-
$this->addToAssertionCount(-1); // dont need to assert this.
2018

2119
return new AddonLicense('test/addon', $response);
2220
}

tests/Licensing/LicenseManagerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ private function managerWithResponse(array $response)
191191
{
192192
$outpost = $this->mock(Outpost::class);
193193

194-
$this->addToAssertionCount(-1); // Dont want to assert this
195-
$outpost->shouldReceive('response')->zeroOrMoreTimes()->andReturn($response);
194+
$outpost->shouldReceive('response')->andReturn($response);
196195

197196
return new LicenseManager($outpost);
198197
}

tests/Markdown/ManagerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public function parser_instances_can_be_saved_and_retrieved()
105105
#[Test]
106106
public function it_throws_an_exception_if_extending_without_returning_a_parser()
107107
{
108-
$this->expectNotToPerformAssertions();
109108
$this->expectException(UnexpectedValueException::class);
110109
$this->expectExceptionMessage('A ['.Markdown\Parser::class.'] instance is expected.');
111110

tests/TestCase.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ protected function setUp(): void
3232
}
3333

3434
if ($this->shouldFakeVersion) {
35-
\Facades\Statamic\Version::shouldReceive('get')->zeroOrMoreTimes()->andReturn('3.0.0-testing');
36-
$this->addToAssertionCount(-1); // Dont want to assert this
35+
\Facades\Statamic\Version::shouldReceive('get')->andReturn('3.0.0-testing');
3736
}
3837

3938
if ($this->shouldPreventNavBeingBuilt) {
40-
\Statamic\Facades\CP\Nav::shouldReceive('build')->zeroOrMoreTimes()->andReturn(collect());
41-
\Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls')->zeroOrMoreTimes();
42-
$this->addToAssertionCount(-2); // Dont want to assert this
39+
\Statamic\Facades\CP\Nav::shouldReceive('build')->andReturn(collect());
40+
\Statamic\Facades\CP\Nav::shouldReceive('clearCachedUrls');
4341
}
4442

4543
$this->addGqlMacros();

0 commit comments

Comments
 (0)