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); |
|
|
|
|
42
|
|
|
yield 'dateFrom: ' . $name => [ |
43
|
|
|
'query' => $query, |
44
|
|
|
'expected' => ['dateFrom' => $expected, 'limit' => 10], |
|
|
|
|
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
|
|
|
|
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.