Completed
Branch master (4d68bf)
by John
01:46
created

DateFormatterBasicTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\CiffRenderer\Test\DateFormatter;
4
5
use Mockery as m;
6
use Urbanplum\DotnetDateTime\DotnetDateTime;
7
use Graze\CiffRenderer\DateFormatter\DateFormatterBasic;
8
use \DateTime;
9
10
class DateFormatterBasicTest extends \PHPUnit_Framework_TestCase
11
{
12
    /**
13
     * @var DotnetDateTime
14
     */
15
    private $dotnetDateTime;
16
17
    /**
18
     * @var DateFormatterBasic
19
     */
20
    private $formatter;
21
22
    public function setUp()
23
    {
24
        $this->dotnetDateTime = m::mock(DotnetDateTime::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like Mockery::mock(Urbanplum\...\DotnetDateTime::class) of type Mockery\MockInterface is incompatible with the declared type Urbanplum\DotnetDateTime\DotnetDateTime of property $dotnetDateTime.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
25
        $this->formatter = new DateFormatterBasic($this->dotnetDateTime);
0 ignored issues
show
Bug introduced by
$this->dotnetDateTime of type Mockery\MockInterface is incompatible with the type Urbanplum\DotnetDateTime\DotnetDateTime expected by parameter $dotnetDateTime of Graze\CiffRenderer\DateF...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

25
        $this->formatter = new DateFormatterBasic(/** @scrutinizer ignore-type */ $this->dotnetDateTime);
Loading history...
26
    }
27
28
    public function testFormat()
29
    {
30
        $formatDotNet = 'i am dot net format';
31
        $formatPhp = 'i am php format';
32
33
        $this->dotnetDateTime
34
            ->shouldReceive('formatToPhp')
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not exist on Urbanplum\DotnetDateTime\DotnetDateTime. ( Ignorable by Annotation )

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

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

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
            ->with($formatDotNet)
36
            ->andReturn($formatPhp)
37
            ->once()
38
            ->getMock();
39
40
        $formatted = 'i am formatted';
41
        $dateTime = m::mock(DateTime::class)
42
            ->shouldReceive('format')
0 ignored issues
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'format'. ( Ignorable by Annotation )

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

42
            ->/** @scrutinizer ignore-call */ shouldReceive('format')

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...
43
            ->with($formatPhp)
44
            ->andReturn($formatted)
45
            ->once()
46
            ->getMock();
47
48
        $actual = $this->formatter->format($dateTime, $formatDotNet);
0 ignored issues
show
Bug introduced by
$dateTime of type Mockery\MockInterface is incompatible with the type DateTimeInterface expected by parameter $date of Graze\CiffRenderer\DateF...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

48
        $actual = $this->formatter->format(/** @scrutinizer ignore-type */ $dateTime, $formatDotNet);
Loading history...
49
50
        $this->assertEquals($formatted, $actual);
51
    }
52
}
53