Skip to content

Commit 6260a8b

Browse files
committed
tests updated
1 parent 088218b commit 6260a8b

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

tests/unit/ArrayView/ReadTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ public function testReadCombined(array $source, callable $viewGetter, array $exp
4242
$this->assertSame($view->toArray(), $expected);
4343
}
4444

45+
/**
46+
* @dataProvider dataProviderForIsAndFilter
47+
*/
48+
public function testIsAndFilter(array $source, callable $predicate, array $expectedMask, array $expectedArray)
49+
{
50+
// Given
51+
$view = ArrayView::toView($source);
52+
53+
// When
54+
$boolMask = $view->is($predicate);
55+
$filtered = $view->filter($predicate);
56+
57+
// Then
58+
$this->assertSame($expectedMask, $boolMask->getValue());
59+
$this->assertSame($expectedArray, $view->subview($boolMask)->toArray());
60+
$this->assertSame($expectedArray, $filtered->toArray());
61+
}
62+
4563
public function dataProviderForArrayRead(): array
4664
{
4765
return [
@@ -174,4 +192,34 @@ public function dataProviderForReadCombine(): array
174192
],
175193
];
176194
}
195+
196+
public function dataProviderForIsAndFilter(): array
197+
{
198+
return [
199+
[
200+
[],
201+
fn (int $x) => $x % 2 === 0,
202+
[],
203+
[],
204+
],
205+
[
206+
[1],
207+
fn (int $x) => $x % 2 === 0,
208+
[false],
209+
[],
210+
],
211+
[
212+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
213+
fn (int $x) => $x % 2 === 0,
214+
[false, true, false, true, false, true, false, true, false, true],
215+
[2, 4, 6, 8, 10],
216+
],
217+
[
218+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
219+
fn (int $_, int $i) => $i % 2 === 0,
220+
[true, false, true, false, true, false, true, false, true, false],
221+
[1, 3, 5, 7, 9],
222+
],
223+
];
224+
}
177225
}

tests/unit/ArrayView/WriteTest.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,6 @@ public function testApplyWith(array $source, callable $viewGetter, callable $map
158158
$this->assertSame($expected, $source);
159159
}
160160

161-
/**
162-
* @dataProvider dataProviderForIsAndFilter
163-
*/
164-
public function testIsAndFilter(array $source, callable $predicate, array $expectedMask, array $expectedArray)
165-
{
166-
// Given
167-
$view = ArrayView::toView($source);
168-
169-
// When
170-
$boolMask = $view->is($predicate);
171-
$filtered = $view->filter($predicate);
172-
173-
// Then
174-
$this->assertSame($expectedMask, $boolMask->getValue());
175-
$this->assertSame($expectedArray, $view->subview($boolMask)->toArray());
176-
$this->assertSame($expectedArray, $filtered->toArray());
177-
}
178-
179161
public function dataProviderForArrayWrite(): array
180162
{
181163
return [
@@ -400,34 +382,4 @@ public function dataProviderForApplyWith(): array
400382
],
401383
];
402384
}
403-
404-
public function dataProviderForIsAndFilter(): array
405-
{
406-
return [
407-
[
408-
[],
409-
fn (int $x) => $x % 2 === 0,
410-
[],
411-
[],
412-
],
413-
[
414-
[1],
415-
fn (int $x) => $x % 2 === 0,
416-
[false],
417-
[],
418-
],
419-
[
420-
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
421-
fn (int $x) => $x % 2 === 0,
422-
[false, true, false, true, false, true, false, true, false, true],
423-
[2, 4, 6, 8, 10],
424-
],
425-
[
426-
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
427-
fn (int $_, int $i) => $i % 2 === 0,
428-
[true, false, true, false, true, false, true, false, true, false],
429-
[1, 3, 5, 7, 9],
430-
],
431-
];
432-
}
433385
}

0 commit comments

Comments
 (0)