Skip to content

Commit

Permalink
More example tests added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Mar 17, 2024
1 parent 98906bd commit db36d26
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/unit/Examples/ExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,29 @@ public function testSelectorsPipe()
$subview[':'] = [55, 77];
$this->assertSame([1, 2, 3, 4, 55, 6, 77, 8, 9, 10], $originalArray);
}

public function testSelectorsPipeNested()
{
$originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

$selector = new PipeSelector([
new SliceSelector('::2'),
new PipeSelector([
new MaskSelector([true, false, true, true, true]),
new IndexListSelector([0, 1, 2]),
]),
new SliceSelector('1:'),
]);

$view = ArrayView::toView($originalArray);
$this->assertTrue(isset($view[$selector]));

$subview = $view->subview($selector);

$this->assertSame([5, 7], $subview->toArray());
$this->assertSame([5, 7], $subview[':']);

$subview[':'] = [55, 77];
$this->assertSame([1, 2, 3, 4, 55, 6, 77, 8, 9, 10], $originalArray);
}
}

0 comments on commit db36d26

Please sign in to comment.