/** * @depends testSet * @param Map * @return void */ public function testGet(Map $mapObject) { $this->assertEquals($mapObject->get(self::$mapKey[0]), self::$mapValue[0]); $this->assertEquals($mapObject->get(self::$mapKey[1]), self::$mapValue[1]); $this->assertEquals($mapObject->get(self::$mapKey[2]), self::$mapValue[2]); $this->assertNull($mapObject->get(self::$mapKey[3])); }
$mapValue[] = new FooString('Value A'); // mapping pair 2 $mapKey[] = 'KeyB'; $mapValue[] = new FooString('Value B'); // mapping pair 3 $mapKey[] = 'KeyC'; $mapValue[] = new FooString('Value C'); // mapping pair 4 $mapKey[] = 'KeyD'; $mapValue[] = new FooString('Value D'); // set 3 mappings to map $mapObject->set($mapKey[0], $mapValue[0]); $mapObject->set($mapKey[1], $mapValue[1]); $mapObject->set($mapKey[2], $mapValue[2]); // get 3 mappings from map echo $mapObject->get($mapKey[0]); // 'Value A' echo $mapObject->get($mapKey[1]); // 'Value B' echo $mapObject->get($mapKey[2]); // 'Value C' echo '<br/>'; // count mappings echo count($mapObject); // 3 // remove mapping with String 'Value B' $mapObject->remove($mapKey[1]); echo '<br/>'; // count mappings echo count($mapObject); // 2