3 class WfArrayFilterTest
extends \PHPUnit_Framework_TestCase
{
4 public function testWfArrayFilter() {
5 $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
6 $filtered = wfArrayFilter( $arr, function ( $val, $key ) {
9 $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
11 $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
12 $filtered = wfArrayFilter( $arr, function ( $val, $key ) {
15 $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
17 $arr = [ 'a', 'b', 'c' ];
18 $filtered = wfArrayFilter( $arr, function ( $val, $key ) {
21 $this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered );
24 public function testWfArrayFilterByKey() {
25 $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
26 $filtered = wfArrayFilterByKey( $arr, function ( $key ) {
29 $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
31 $arr = [ 'a', 'b', 'c' ];
32 $filtered = wfArrayFilterByKey( $arr, function ( $key ) {
35 $this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered );