Completed
Pull Request — master (#17)
by
unknown
18:59
created

DateTimeCreatorTest::testGetNowDateTimePHP71()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
//namespace Smartbox\CoreBundle\Tests\Utils\Helper;
4
//
5
//use Smartbox\CoreBundle\Utils\Helper\DateTimeCreator;
6
//use Symfony\Bridge\PhpUnit\ClockMock;
7
//
8
///**
9
// * @coversDefaultClass \Smartbox\CoreBundle\Utils\Helper\DateTimeCreator
10
// */
11
//class DateTimeCreatorTest extends \PHPUnit\Framework\TestCase
12
//{
13
//    /**
14
//     * @covers ::getNowDateTime
15
//     * @dataProvider microtimeProvider
16
//     *
17
//     * @param $microtime
18
//     * @param $expectedDateTime
19
//     * @throws \ReflectionException
20
//     */
21
//    public function testGetNowDateTimePHP70($microtime, $expectedDateTime)
22
//    {
23
//        if (PHP_VERSION_ID >= 70100) {
24
//            $this->markTestSkipped('Skipped as using a different method to create a datetime');
25
//        }
26
//
27
//        $clockReflection = new \ReflectionClass(ClockMock::class);
28
//
29
//        $reflectionProperty = $clockReflection->getProperty('now');
30
//        $reflectionProperty->setAccessible(true);
31
//        $reflectionProperty->setValue($microtime);
32
//
33
//        ClockMock::register(DateTimeCreator::class);
34
//
35
//        $datetime = DateTimeCreator::getNowDateTime();
36
//
37
//        $this->assertEquals($expectedDateTime, $datetime);
38
//    }
39
//
40
//    /**
41
//     * @covers ::getNowDateTime
42
//     */
43
//    public function testGetNowDateTimePHP71()
44
//    {
45
//        if (PHP_VERSION_ID < 70100) {
46
//            $this->markTestSkipped('Skipped as using a different method to create date time');
47
//        }
48
//
49
//        $datetime = DateTimeCreator::getNowDateTime();
50
//
51
//        $this->assertInstanceOf(\DateTime::class, $datetime);
52
//    }
53
//
54
//    public function microtimeProvider()
55
//    {
56
//        return [
57
//            'with-decimal' => [
58
//                1544538334.9465,
59
//                new \DateTime('2018-12-11 14:25:34.946500'),
60
//            ],
61
//            'without-decimal' => [
62
//                1544538334,
63
//                new \DateTime('2018-12-11 14:25:34.000000'),
64
//            ],
65
//            'with-decimal-zero' => [
66
//                1544538334.0,
67
//                new \DateTime('2018-12-11 14:25:34.000000'),
68
//            ],
69
//        ];
70
//    }
71
//}
72