public function testCategorizeByKey() { $this->assertCount(0, ArrayUtils::categorizeByKey($this->_getArrayPreset('empty_array'), 'id')); $this->assertCount(5, ArrayUtils::categorizeByKey($this->_getArrayPreset('2D_collection_5'), 'id')); $this->assertCount(3, ArrayUtils::categorizeByKey($this->_getArrayPreset('2D_collection_5'), 'categoryId')); $byCategoryId = ArrayUtils::categorizeByKey($this->_getArrayPreset('2D_collection_5_named'), 'categoryId'); $this->assertCount(3, $byCategoryId); $this->assertArrayHasKey(3, $byCategoryId); $this->assertArrayNotHasKey('sit', $byCategoryId[3]); $byCategoryIdNamed = ArrayUtils::categorizeByKey($this->_getArrayPreset('2D_collection_5_named'), 'categoryId', true); $this->assertCount(3, $byCategoryIdNamed); $this->assertArrayHasKey(3, $byCategoryIdNamed); $this->assertArrayHasKey('sit', $byCategoryIdNamed[3]); $this->assertCount(0, ArrayUtils::categorizeByKey($this->_getArrayPreset('2D_collection_5'), 'undefined')); }