alex-patterson-webdev /
date-time
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace ArpTest\DateTime\Psr; |
||
| 6 | |||
| 7 | use Arp\DateTime\DateTimeImmutableFactory; |
||
| 8 | use Arp\DateTime\Psr\SystemClock; |
||
| 9 | use PHPUnit\Framework\MockObject\MockObject; |
||
| 10 | use PHPUnit\Framework\TestCase; |
||
| 11 | use Psr\Clock\ClockInterface; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @covers \Arp\DateTime\Psr\SystemClock |
||
| 15 | */ |
||
| 16 | final class SystemClockTest extends TestCase |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var DateTimeImmutableFactory&MockObject |
||
| 20 | */ |
||
| 21 | private DateTimeImmutableFactory $factory; |
||
| 22 | |||
| 23 | public function setUp(): void |
||
| 24 | { |
||
| 25 | $this->factory = $this->createMock(DateTimeImmutableFactory::class); |
||
| 26 | } |
||
| 27 | |||
| 28 | public function testImplementsClockInterface(): void |
||
| 29 | { |
||
| 30 | $this->assertInstanceOf(ClockInterface::class, new SystemClock($this->factory)); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @throws \Exception |
||
| 35 | */ |
||
| 36 | public function testNow(): void |
||
| 37 | { |
||
| 38 | $clock = new SystemClock($this->factory); |
||
| 39 | |||
| 40 | $systemTimeZone = date_default_timezone_get(); |
||
| 41 | $dateTimeImmutable = new \DateTimeImmutable('now', new \DateTimeZone($systemTimeZone)); |
||
| 42 | |||
| 43 | $this->factory->expects($this->once()) |
||
|
0 ignored issues
–
show
|
|||
| 44 | ->method('createDateTime') |
||
| 45 | ->with('now', $systemTimeZone) |
||
| 46 | ->willReturn($dateTimeImmutable); |
||
| 47 | |||
| 48 | $this->assertSame($dateTimeImmutable, $clock->now()); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.