Skip to content

Commit

Permalink
Add tests for calling with Traversable
Browse files Browse the repository at this point in the history
  • Loading branch information
dpolac committed May 7, 2016
1 parent da1f4d4 commit f941613
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Tests/Fixtures/filters/any.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NO
NO
NO
--DATA--
return [ 'data' => [-1, -7, 13, 1, 5] ];
return [ 'data' => new ArrayIterator([-1, -7, 13, 1, 5]) ];
--EXPECT--
YES
NO
Expand Down
13 changes: 13 additions & 0 deletions Tests/Fixtures/filters/count_by.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ foo: 3
foobar: 1
bar: 2
--DATA--
return [ 'data' => new ArrayIterator([
[ 'foo' => 'foo' ],
[ 'foo' => 'foo' ],
[ 'foo' => 'foobar' ],
[ 'foo' => 'bar' ],
[ 'foo' => 'bar' ],
[ 'foo' => 'foo' ],
]) ];
--EXPECT--
foo: 3
foobar: 1
bar: 2
--DATA--
return [ 'data' => [
[ 'foo' => null, 'bar' => 1 ],
[ 'foo' => null, 'bar' => 2 ],
Expand Down
14 changes: 14 additions & 0 deletions Tests/Fixtures/filters/count_by_key.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,18 @@ return [ 'data' => [
f: 2
b: 2
t: 1
2: 1
--DATA--
return [ 'data' => new ArrayIterator([
'foo' => 1,
'bar' => null,
'foobar' => [1, 2],
'tetbar' => "abc",
'barbar' => 12,
2001 => 12,
]) ];
--EXPECT--
f: 2
b: 2
t: 1
2: 1
2 changes: 1 addition & 1 deletion Tests/Fixtures/filters/every.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NO
YES
YES
--DATA--
return [ 'data' => [-2, -8, 14, 2, 6] ];
return [ 'data' => new ArrayIterator([-2, -8, 14, 2, 6]) ];
--EXPECT--
NO
YES
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/filters/filter.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ return [ 'data' => [ 1, 2, 3, 4, 5, 6 ] ];
3: 4
5: 6
--DATA--
return [ 'data' => [ 1, 2, 3, 4, 5, 6 ] ];
return [ 'data' => new ArrayIterator([ 1, 2, 3, 4, 5, 6 ]) ];
--EXPECT--
1: 2
3: 4
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/filters/group_by.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ return [ 'data' => [ 'foo', 'bar', 'tet' ] ];
= t
* tet
--DATA--
return [ 'data' => [ 'foo', 'foobar', 'tet', 'bar', 'tetfoo' ] ];
return [ 'data' => new ArrayIterator([ 'foo', 'foobar', 'tet', 'bar', 'tetfoo' ]) ];
--EXPECT--
= f
* foo
Expand Down
15 changes: 15 additions & 0 deletions Tests/Fixtures/filters/group_by_key.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ return [ 'data' => [
'tet' => 3,
'foobar' => 4,
] ];
--EXPECT--
= f
* 1
* 4
= b
* 2
= t
* 3
--DATA--
return [ 'data' => new ArrayIterator([
'foo' => 1,
'bar' => 2,
'tet' => 3,
'foobar' => 4,
]) ];
--EXPECT--
= f
* 1
Expand Down
20 changes: 20 additions & 0 deletions Tests/Fixtures/filters/map.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ return [ 'data' => [
[ 'FOO' => 4, 'BAR' => 'd' ],
[ 'FOO' => 5, 'BAR' => 'e' ],
] ];
--EXPECT--
* 2
* 3
* 4
* 5
* 6
====
* a
* b
* c
* d
* e
--DATA--
return [ 'data' => new \ArrayIterator([
[ 'FOO' => 1, 'BAR' => 'a' ],
[ 'FOO' => 2, 'BAR' => 'b' ],
[ 'FOO' => 3, 'BAR' => 'c' ],
[ 'FOO' => 4, 'BAR' => 'd' ],
[ 'FOO' => 5, 'BAR' => 'e' ],
]) ];
--EXPECT--
* 2
* 3
Expand Down
12 changes: 12 additions & 0 deletions Tests/Fixtures/filters/map_key.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ return [ 'data' => [
12 => 'c',
'am' => 4,
] ];
--EXPECT--
* ab
* cdef
* 12c
* am4
--DATA--
return [ 'data' => new ArrayIterator([
'a' => 'b',
'cd' => 'ef',
12 => 'c',
'am' => 4,
]) ];
--EXPECT--
* ab
* cdef
Expand Down
14 changes: 14 additions & 0 deletions Tests/Fixtures/filters/sort_by.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ return [ 'data' => [
[ 'foo' => 'd', 'bar' => -1 ],
[ 'foo' => 'e', 'bar' => 20 ],
] ];
--EXPECT--
* b
* d
* a
* c
* e
--DATA--
return [ 'data' => new ArrayIterator([
[ 'foo' => 'a', 'bar' => 20 ],
[ 'foo' => 'b', 'bar' => -1 ],
[ 'foo' => 'c', 'bar' => 20 ],
[ 'foo' => 'd', 'bar' => -1 ],
[ 'foo' => 'e', 'bar' => 20 ],
]) ];
--EXPECT--
* b
* d
Expand Down
14 changes: 14 additions & 0 deletions Tests/Fixtures/filters/sort_by_key.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,18 @@ e: 3
d: 2
c: 5
b: 1
a: 4
--DATA--
return [ 'data' => new ArrayIterator([
'b' => 1,
'd' => 2,
'e' => 3,
'a' => 4,
'c' => 5,
]) ];
--EXPECT--
e: 3
d: 2
c: 5
b: 1
a: 4
6 changes: 6 additions & 0 deletions Tests/Fixtures/filters/unique.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ return [ 'data' => [1, 2, 1, 3] ];
* 2
* 3
--DATA--
return [ 'data' => new ArrayIterator([1, 3, 1, 2, 3]) ];
--EXPECT--
* 1
* 3
* 2
--DATA--
return [ 'data' => ['foo', 'bar', 'foo'] ]
--EXPECT--
* foo
Expand Down

0 comments on commit f941613

Please sign in to comment.