Skip to content

Commit 26736e0

Browse files
committed
Array strict list test.
1 parent c060a26 commit 26736e0

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* @author Anton Lytkin <a.lytkin@worksolutions.ru>
4+
*/
5+
6+
namespace WS\Utils\Collections;
7+
8+
use InvalidArgumentException;
9+
use PHPUnit\Framework\TestCase;
10+
11+
class ArrayStrictListTest extends TestCase
12+
{
13+
public function createInstance(...$args): ListSequence
14+
{
15+
return ArrayStrictList::of(...$args);
16+
}
17+
18+
public function strictCases(): array
19+
{
20+
return [
21+
[1, 2, 3],
22+
[1.1, 2.2, 3.3],
23+
['one', 'two', 'three'],
24+
[true, false, true],
25+
[[1], ['2'], [3.3]],
26+
[null, null, null],
27+
[
28+
function () {
29+
return '1';
30+
},
31+
function () {
32+
return 'two';
33+
},
34+
function () {
35+
return 3;
36+
},
37+
],
38+
[
39+
$object = new class () {
40+
},
41+
clone $object,
42+
clone $object,
43+
],
44+
];
45+
}
46+
47+
public function notStrictCases(): array
48+
{
49+
return [
50+
[1, '2', 3],
51+
[1.1, 2.2, 3],
52+
['one', 'two', 3.3],
53+
['true', false, true],
54+
[[1], null, [3.3]],
55+
[null, null, []],
56+
[
57+
function () {
58+
return '1';
59+
},
60+
new class () {
61+
},
62+
function () {
63+
return 3;
64+
},
65+
],
66+
[
67+
$object = new class () {
68+
},
69+
clone $object,
70+
new class () {
71+
},
72+
],
73+
];
74+
}
75+
76+
/**
77+
* @test
78+
* @dataProvider strictCases
79+
* @doesNotPerformAssertions
80+
* @param $sequence
81+
*/
82+
public function creatingFromStrict(...$sequence): void
83+
{
84+
$this->createInstance(...$sequence);
85+
}
86+
87+
/**
88+
* @test
89+
* @dataProvider notStrictCases
90+
* @param $sequence
91+
*/
92+
public function creatingFromNotStrict(...$sequence): void
93+
{
94+
self::expectException(InvalidArgumentException::class);
95+
$this->createInstance(...$sequence);
96+
}
97+
}

0 commit comments

Comments
 (0)