Skip to content

Commit 9ed7749

Browse files
committed
Avoid double casting
1 parent 57a6ec5 commit 9ed7749

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

test/unit/Command/AssertBackwardsCompatibleTest.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ public function testExecuteWhenRevisionsAreProvidedAsOptions(): void
141141
$this->performCheckout->expects(self::exactly(2))
142142
->method('checkout')
143143
->willReturnCallback(function (CheckedOutRepository $repository, Revision $sha) use ($fromSha, $toSha) {
144+
$stringRevision = (string) $sha;
145+
144146
self::assertEquals($repository, $this->sourceRepository);
145-
self::assertTrue((string) $sha === $fromSha || (string) $sha === $toSha);
147+
self::assertTrue($stringRevision === $fromSha || $stringRevision === $toSha);
146148

147149
return $this->sourceRepository;
148150
});
@@ -204,8 +206,10 @@ public function testExecuteWhenDevelopmentDependenciesAreRequested(): void
204206
$this->performCheckout->expects(self::exactly(2))
205207
->method('checkout')
206208
->willReturnCallback(function (CheckedOutRepository $repository, Revision $sha) use ($fromSha, $toSha) {
209+
$stringRevision = (string) $sha;
210+
207211
self::assertEquals($repository, $this->sourceRepository);
208-
self::assertTrue((string) $sha === $fromSha || (string) $sha === $toSha);
212+
self::assertTrue($stringRevision === $fromSha || $stringRevision === $toSha);
209213

210214
return $this->sourceRepository;
211215
});
@@ -268,8 +272,10 @@ public function testExecuteReturnsNonZeroExitCodeWhenChangesAreDetected(): void
268272
$this->performCheckout->expects(self::exactly(2))
269273
->method('checkout')
270274
->willReturnCallback(function (CheckedOutRepository $repository, Revision $sha) use ($fromSha, $toSha) {
275+
$stringRevision = (string) $sha;
276+
271277
self::assertEquals($repository, $this->sourceRepository);
272-
self::assertTrue((string) $sha === $fromSha || (string) $sha === $toSha);
278+
self::assertTrue($stringRevision === $fromSha || $stringRevision === $toSha);
273279

274280
return $this->sourceRepository;
275281
});
@@ -344,8 +350,10 @@ public function testProvidingMarkdownOptionWritesMarkdownOutput(): void
344350
$this->performCheckout->expects(self::exactly(2))
345351
->method('checkout')
346352
->willReturnCallback(function (CheckedOutRepository $repository, Revision $sha) use ($fromSha, $toSha) {
353+
$stringRevision = (string) $sha;
354+
347355
self::assertEquals($repository, $this->sourceRepository);
348-
self::assertTrue((string) $sha === $fromSha || (string) $sha === $toSha);
356+
self::assertTrue($stringRevision === $fromSha || $stringRevision === $toSha);
349357

350358
return $this->sourceRepository;
351359
});
@@ -457,8 +465,10 @@ public function testExecuteWithDefaultRevisionsNotProvided(VersionCollection $ve
457465
$this->performCheckout->expects(self::exactly(2))
458466
->method('checkout')
459467
->willReturnCallback(function (CheckedOutRepository $repository, Revision $sha) use ($fromSha, $toSha) {
468+
$stringRevision = (string) $sha;
469+
460470
self::assertEquals($repository, $this->sourceRepository);
461-
self::assertTrue((string) $sha === $fromSha || (string) $sha === $toSha);
471+
self::assertTrue($stringRevision === $fromSha || $stringRevision === $toSha);
462472

463473
return $this->sourceRepository;
464474
});

0 commit comments

Comments
 (0)