예제 #1
0
 public function testFilter()
 {
     $this->assertCount(0, ArrayUtils::filter($this->_getArrayPreset('empty_array'), 'id', 1));
     $this->assertCount(1, ArrayUtils::filter($this->_getArrayPreset('2D_collection_5'), 'id', 1));
     $this->assertCount(2, ArrayUtils::filter($this->_getArrayPreset('2D_collection_5'), 'categoryId', '5'));
     $this->assertCount(2, ArrayUtils::filter($this->_getArrayPreset('2D_collection_5_named'), 'categoryId', 5));
     $this->assertEmpty(ArrayUtils::filter($this->_getArrayPreset('2D_collection_5'), 'categoryId', 999));
     $this->assertArrayHasKey('sit', ArrayUtils::filter($this->_getArrayPreset('2D_collection_5_named'), 'name', 'sit', true));
     $this->assertArrayNotHasKey('sit', ArrayUtils::filter($this->_getArrayPreset('2D_collection_5_named'), 'name', 'sit'));
 }