public function countValues() { try { /** * We must mute errors in this function because it throws a E_WARNING message if array contains something * else than STRING or INTEGER. */ @($result = array_count_values($this->val())); return new ArrayObject($result); } catch (\ErrorException $e) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_COUNT_VALUES); } }
/** * @dataProvider arraySet2 */ public function testCountValues($array) { $a = new ArrayObject($array); $valueCount = $a->countValues(); $this->assertSame(array_count_values($array), $valueCount->val()); }