|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Fixture; |
| 6 | + |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | +use Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests; |
| 9 | + |
| 10 | +final class TwoAssertsRightAfterEachOther extends TestCase |
| 11 | +{ |
| 12 | + public function test(): void |
| 13 | + { |
| 14 | + $someObject = $this->getSomeObject(); |
| 15 | + $this->assertSame(123, $someObject->getSomeMethod()); |
| 16 | + |
| 17 | + $someObject2 = $this->getSomeObject(); |
| 18 | + $this->assertSame(456, $someObject2->getSomeMethod()); |
| 19 | + } |
| 20 | + |
| 21 | + private function getSomeObject(): ?SomeClassUsedInTests |
| 22 | + { |
| 23 | + if (mt_rand(0, 1)) { |
| 24 | + return new SomeClassUsedInTests(); |
| 25 | + } |
| 26 | + |
| 27 | + return null; |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +?> |
| 32 | +----- |
| 33 | +<?php |
| 34 | + |
| 35 | +declare(strict_types=1); |
| 36 | + |
| 37 | +namespace Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Fixture; |
| 38 | + |
| 39 | +use PHPUnit\Framework\TestCase; |
| 40 | +use Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests; |
| 41 | + |
| 42 | +final class TwoAssertsRightAfterEachOther extends TestCase |
| 43 | +{ |
| 44 | + public function test(): void |
| 45 | + { |
| 46 | + $someObject = $this->getSomeObject(); |
| 47 | + $this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject); |
| 48 | + $this->assertSame(123, $someObject->getSomeMethod()); |
| 49 | + |
| 50 | + $someObject2 = $this->getSomeObject(); |
| 51 | + $this->assertInstanceOf(\Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector\Source\SomeClassUsedInTests::class, $someObject2); |
| 52 | + $this->assertSame(456, $someObject2->getSomeMethod()); |
| 53 | + } |
| 54 | + |
| 55 | + private function getSomeObject(): ?SomeClassUsedInTests |
| 56 | + { |
| 57 | + if (mt_rand(0, 1)) { |
| 58 | + return new SomeClassUsedInTests(); |
| 59 | + } |
| 60 | + |
| 61 | + return null; |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +?> |
0 commit comments