Completed
Push — refactor-04-parser-tests ( dc4950...bd4663 )
by John
06:06
created

DateFormatterBasicTest::testFormat()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 0
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Unit\Parser\FieldParser\DateFormatter;
4
5
use Mockery as m;
6
use Urbanplum\DotnetDateTime\DotnetDateTime;
7
use Graze\CiffRenderer\Parser\FieldParser\DateFormatter\DateFormatterBasic;
8
9
class DateFormatterBasicTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testFormat()
12
    {
13
        $formatDotNet = 'i am format dotnet';
14
        $formatPhp = 'i am format php';
15
        $dotnetDateTime = m::mock(DotnetDateTime::class)
16
            ->shouldReceive('formatToPhp')
17
            ->with($formatDotNet)
18
            ->andReturn($formatPhp)
19
            ->once()
20
            ->getMock();
21
22
        $expected = 'i am expected';
23
        $date = m::mock(\DateTimeImmutable::class)
24
            ->shouldReceive('format')
25
            ->with($formatPhp)
26
            ->andReturn($expected)
27
            ->once()
28
            ->getMock();
29
30
        $formatter = new DateFormatterBasic($dotnetDateTime);
31
        $actual = $formatter->format($date, $formatDotNet);
32
33
        $this->assertSame($expected, $actual);
34
    }
35
}
36