/** * @depends testOffsetSet * @depends testOffsetUnset */ function testIsEmpty() { $map = new SortedMap(); $this->assertTrue($map->isEmpty()); $this->assertTrue($map->getIterator()->isEmpty()); $map[0] = 0; $this->assertFalse($map->isEmpty()); $this->assertFalse($map->getIterator()->isEmpty()); unset($map[0]); $this->assertTrue($map->isEmpty()); $this->assertTrue($map->getIterator()->isEmpty()); }
function testIterator() { $map = new SortedMap(); $map[0] = 1; $map[2] = 3; $map[3] = 4; $map[1] = 2; $iterator = $map->getIterator(); $this->assertInstanceOf('Collections\\SortedMapIterator', $iterator); $this->assertCount(count($map), $iterator); $iterator->rewind(); for ($i = 0; $i < count($map); $i++) { $this->assertTrue($iterator->valid()); $this->assertEquals($i, $iterator->key()); $expectedValue = $map[$i]; $this->assertEquals($expectedValue, $iterator->current()); $iterator->next(); } $this->assertFalse($iterator->valid()); $this->assertCount(count($map), $iterator); }