|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Test\AbraFlexi; |
| 4 | + |
| 5 | +use AbraFlexi\DateTime; |
| 6 | + |
| 7 | +/** |
| 8 | + * Generated by PHPUnit_SkeletonGenerator on 2021-10-19 at 15:21:39. |
| 9 | + */ |
| 10 | +class DateTimeTest extends \PHPUnit\Framework\TestCase { |
| 11 | + |
| 12 | + /** |
| 13 | + * @var DateTime |
| 14 | + */ |
| 15 | + protected $object; |
| 16 | + |
| 17 | + /** |
| 18 | + * Sets up the fixture, for example, opens a network connection. |
| 19 | + * This method is called before a test is executed. |
| 20 | + */ |
| 21 | + protected function setUp(): void { |
| 22 | + $this->object = new DateTime(); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Tears down the fixture, for example, closes a network connection. |
| 27 | + * This method is called after a test is executed. |
| 28 | + */ |
| 29 | + protected function tearDown(): void { |
| 30 | + |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Test Constructor |
| 35 | + * |
| 36 | + * @covers AbraFlexi\DateTime::__construct |
| 37 | + */ |
| 38 | + public function testConstructor() { |
| 39 | + $classname = get_class($this->object); |
| 40 | + |
| 41 | + // Get mock, without the constructor being called |
| 42 | + $mock = $this->getMockBuilder($classname) |
| 43 | + ->disableOriginalConstructor() |
| 44 | + ->getMockForAbstractClass(); |
| 45 | + |
| 46 | + $mock->__construct(''); |
| 47 | + $this->assertTrue($mock->isNull); |
| 48 | + |
| 49 | + $mock->__construct('NOW'); |
| 50 | + $this->assertFalse($mock->isNull); |
| 51 | + $mock->__construct('2021-11-09T12:03:53++00:00'); |
| 52 | + |
| 53 | + $mock->__construct('2021-10-19T15:12:53.435+02:00'); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * @covers AbraFlexi\DateTime::__toString |
| 58 | + */ |
| 59 | + public function test__toString() { |
| 60 | + $this->object->setDate(2323, 2, 3)->setTime(2, 3, 2, 3); |
| 61 | + $this->assertEquals('2323-02-03T02:03:02.000003++00:00', $this->object->__toString()); |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments