xref: /PHP-7.1/ext/spl/tests/bug66702.phpt (revision 113213f0)
1--TEST--
2Bug #66702 (RegexIterator inverted result works as expected)
3--FILE--
4<?php
5/**
6 * @author Joshua Thijssen <jthijssen+php@noxlogic.nl>
7 */
8
9$it = new \ArrayIterator(array("foo", "bar", "baz"));
10$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH);
11print_r(iterator_to_array($it2));
12$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::INVERT_MATCH);
13print_r(iterator_to_array($it2));
14
15$it = new \ArrayIterator(array("foo" => 1, "bar" => 2, "baz" => 3));
16$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::USE_KEY);
17print_r(iterator_to_array($it2));
18$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::USE_KEY | \RegexIterator::INVERT_MATCH);
19print_r(iterator_to_array($it2));
20--EXPECTF--
21Array
22(
23    [1] => bar
24    [2] => baz
25)
26Array
27(
28    [0] => foo
29)
30Array
31(
32    [bar] => 2
33    [baz] => 3
34)
35Array
36(
37    [foo] => 1
38)
39