Completed
Push — master ( fd3130...674c45 )
by John
03:39
created

DateFormatterBasicTest::testFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 23
rs 9.6666
c 0
b 0
f 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')
0 ignored issues
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'formatToPhp'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
            ->/** @scrutinizer ignore-call */ shouldReceive('formatToPhp')

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
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);
0 ignored issues
show
Bug introduced by
$dotnetDateTime of type Mockery\MockInterface is incompatible with the type Urbanplum\DotnetDateTime\DotnetDateTime expected by parameter $dotnetDateTime of Graze\CiffRenderer\Parse...terBasic::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        $formatter = new DateFormatterBasic(/** @scrutinizer ignore-type */ $dotnetDateTime);
Loading history...
31
        $actual = $formatter->format($date, $formatDotNet);
0 ignored issues
show
Bug introduced by
$date of type Mockery\MockInterface is incompatible with the type DateTimeInterface expected by parameter $date of Graze\CiffRenderer\Parse...ormatterBasic::format(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        $actual = $formatter->format(/** @scrutinizer ignore-type */ $date, $formatDotNet);
Loading history...
32
33
        $this->assertSame($expected, $actual);
34
    }
35
}
36