$collectionObject->add(12); echo 'Count: '; echo count($collectionObject); echo '<br/>'; echo 'Add 13, 14, 15 and 16 as a array: '; echo '<br/>'; $collectionObject->addAll(array(13, 14, 15, 16)); echo 'Count: '; echo count($collectionObject); echo '<br/>'; echo '<br/>'; echo '<br/>'; echo 'remove value: '; echo '<br/>'; $collectionObject = new Collection(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); $collectionObject->remove(4); $collectionObject->remove(10); echo 'Count: '; echo count($collectionObject); echo '<br/>'; echo '<br/>'; echo '<br/>'; echo 'is empty (has any entries): '; if ($collectionObject->isEmpty()) { echo 'FALSE'; } else { echo 'TRUE'; } echo '<br/>'; echo 'clear list'; $collectionObject->clear();
/** * @return void */ public function testRemove() { $collectionObject = new Collection(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); $collectionObject->remove(4); $collectionObject->remove(10); $array = array(); foreach ($collectionObject as $key => $value) { $array[] = $value; } $this->assertEquals(8, count($array)); $this->assertEquals(1, $array[0]); $this->assertEquals(2, $array[1]); $this->assertEquals(3, $array[2]); $this->assertEquals(5, $array[3]); $this->assertEquals(6, $array[4]); $this->assertEquals(7, $array[5]); $this->assertEquals(8, $array[6]); $this->assertEquals(9, $array[7]); }