use Naucon\Utility\HashMap; class FooString { protected $value = null; public function __construct($value) { $this->value = $value; } public function __toString() { return $this->value; } } // init hash map $hashMapObject = new HashMap(); // mapping pair 1 $mapKey[] = new FooString('Key A'); $mapValue[] = new FooString('Value A'); // mapping pair 2 $mapKey[] = new FooString('Key B'); $mapValue[] = new FooString('Value B'); // mapping pair 3 $mapKey[] = new FooString('Key C'); $mapValue[] = new FooString('Value C'); // mapping pair 4 $mapKey[] = new FooString('Key D'); $mapValue[] = new FooString('Value D'); // set 3 mappings to map $hashMapObject->set($mapKey[0], $mapValue[0]); $hashMapObject->set($mapKey[1], $mapValue[1]);
/** * @depends testSet * @param HashMap * @return void */ public function testClear(HashMap $hashMapObject) { $hashMapObject->clear(); $this->assertEquals(count($hashMapObject), 0); $this->assertNull($hashMapObject->get(self::$mapKey[0])); $this->assertNull($hashMapObject->get(self::$mapKey[1])); $this->assertNull($hashMapObject->get(self::$mapKey[2])); $this->assertNull($hashMapObject->get(self::$mapKey[3])); }