Esempio n. 1
0
 public function testRemoveItem()
 {
     $items = $this->createRandomItems();
     $items_count = count($items);
     $last_index = $items_count - 1;
     $random_index = 0;
     // pick a random item from the list data to be removed
     if ($last_index > 0) {
         $random_index = self::$faker->numberBetween(0, $last_index);
     }
     $random_item = $items[$random_index];
     $list = new ArrayList($items);
     $list->removeItem($random_item);
     // assert item count
     $expected_item_count = $items_count - 1;
     $this->assertEquals($expected_item_count, count($list));
     // assert item order
     $expected_items = [];
     foreach ($items as $index => $item) {
         if ($index !== $random_index) {
             $expected_items[] = $item;
         }
     }
     foreach ($list as $index => $item) {
         $this->assertEquals($expected_items[$index], $item);
     }
 }