public function testGetKey() { $items = $this->createRandomItems(); $items_count = count($items); $last_index = $items_count - 1; // pick a random item from the list to test against $random_key = 0; if ($last_index > 0) { $random_key = self::$faker->numberBetween(0, $last_index); } $random_item = $items[$random_key]; $list = new ArrayList($items); $this->assertEquals($random_key, $list->getKey($random_item)); }