Completed
Push — 2.0 ( 0357a9...3fe951 )
by Peter
08:22 queued 10s
created

DateDiffExecutorSpec::getMatchers()   B

Complexity

Conditions 7
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 8.8333
c 0
b 0
f 0
cc 7
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of the Happyr Doctrine Specification package.
6
 *
7
 * (c) Tobias Nyholm <[email protected]>
8
 *     Kacper Gunia <[email protected]>
9
 *     Peter Gribanov <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace tests\Happyr\DoctrineSpecification\Operand\PlatformFunction\Executor;
16
17
use Happyr\DoctrineSpecification\Operand\PlatformFunction\Executor\DateDiffExecutor;
18
use PhpSpec\ObjectBehavior;
19
20
/**
21
 * @mixin DateDiffExecutor
22
 */
23
final class DateDiffExecutorSpec extends ObjectBehavior
24
{
25
    public function it_should_make_a_date_diff(): void
26
    {
27
        $date1 = new \DateTimeImmutable('2019-01-12 11:24:46');
28
        $date2 = new \DateTimeImmutable('2020-12-17 17:31:12');
29
30
        $this($date1, $date2)->shouldBeSameDateInterval($date1->diff($date2));
31
    }
32
33
    public function getMatchers(): array
34
    {
35
        return [
36
            'beSameDateInterval' => function (\DateInterval $subject, \DateInterval $expected): bool {
37
                return
38
                    $subject->y === $expected->y &&
39
                    $subject->m === $expected->m &&
40
                    $subject->d === $expected->d &&
41
                    $subject->h === $expected->h &&
42
                    $subject->i === $expected->i &&
43
                    $subject->s === $expected->s &&
44
                    $subject->invert === $expected->invert
45
                ;
46
            },
47
        ];
48
    }
49
}
50