Completed
Push — master ( 9c9a38...41b06d )
by Agaletskiy
01:37
created

FacadeDocListV2QueryTest::testToQueryArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\IsmpClient\Tests\V3\Dto;
6
7
use Lamoda\IsmpClient\V3\Dto\FacadeDocListV2Query;
8
use PHPUnit\Framework\TestCase;
9
10
final class FacadeDocListV2QueryTest extends TestCase
11
{
12
    /**
13
     * @dataProvider dataToQueryArray
14
     */
15
    public function testToQueryArray(FacadeDocListV2Query $query, array $expected): void
16
    {
17
        $this->assertSame($expected, $query->toQueryArray());
18
    }
19
20
    public function dataToQueryArray(): iterable
21
    {
22
        $query = new FacadeDocListV2Query();
23
        yield 'query without parameters' => [
24
            'query' => $query,
25
            'expected' => ['limit' => 10],
26
        ];
27
28
        $dateTests = [
29
            'DateTime in UTC timezone' => [
30
                new \DateTime('2019-12-16 18:45:11', new \DateTimeZone('UTC')),
31
                '2019-12-16T18:45:11.000+00:00',
32
            ],
33
            'DateTimeImmutable in custom timezone' => [
34
                new \DateTimeImmutable('2019-12-16 18:45:11', new \DateTimeZone('Europe/Moscow')),
35
                '2019-12-16T18:45:11.000+03:00',
36
            ],
37
        ];
38
39
        foreach ($dateTests as $name => [$date, $expected]) {
40
            $query = new FacadeDocListV2Query();
41
            $query->setDateFrom($date);
0 ignored issues
show
Bug introduced by
The variable $date does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
42
            yield 'dateFrom: ' . $name => [
43
                'query' => $query,
44
                'expected' => ['dateFrom' => $expected, 'limit' => 10],
0 ignored issues
show
Bug introduced by
The variable $expected does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
45
            ];
46
47
            $query = new FacadeDocListV2Query();
48
            $query->setDateTo($date);
49
            yield 'dateTo: ' . $name => [
50
                'query' => $query,
51
                'expected' => ['dateTo' => $expected, 'limit' => 10],
52
            ];
53
        }
54
    }
55
}
56