-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArrayNormalizerTest.php
More file actions
62 lines (53 loc) · 1.43 KB
/
ArrayNormalizerTest.php
File metadata and controls
62 lines (53 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php declare(strict_types=1);
namespace Tests\Torr\SimpleNormalizer\Normalizer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Torr\SimpleNormalizer\Test\SimpleNormalizerTestTrait;
/**
* @internal
*/
final class ArrayNormalizerTest extends TestCase
{
use SimpleNormalizerTestTrait;
/**
*
*/
public static function provideListArray () : iterable
{
yield [[1, 2, 3, 4], [1, 2, 3, 4]];
yield [[1, null, 3, null], [1, 3]];
yield [[], []];
yield [[null], []];
}
/**
*
*/
#[DataProvider("provideListArray")]
public function testListArray (array $input, array $expected) : void
{
$normalizer = $this->createNormalizer();
$actual = $normalizer->normalize($input);
self::assertSame($expected, $actual);
self::assertTrue(array_is_list($actual));
}
/**
*
*/
public static function provideAssociativeArray () : iterable
{
yield [["a" => 1, "b" => 2, "c" => 3, "d" => 4], ["a" => 1, "b" => 2, "c" => 3, "d" => 4]];
yield [["a" => 1, "b" => null, "c" => 3, "d" => null], ["a" => 1, "b" => null, "c" => 3, "d" => null]];
yield [["empty" => null], ["empty" => null]];
}
/**
*
*/
#[DataProvider("provideAssociativeArray")]
public function testAssociativeArray (array $input, array $expected) : void
{
$normalizer = $this->createNormalizer();
$actual = $normalizer->normalize($input);
self::assertSame($expected, $actual);
self::assertFalse(array_is_list($actual));
}
}