Exemple #1
0
 /**
  * @depends  testSet
  * @param    Map
  * @return   void
  */
 public function testClear(Map $mapObject)
 {
     $mapObject->clear();
     $this->assertEquals(count($mapObject), 0);
     $this->assertNull($mapObject->get(self::$mapKey[0]));
     $this->assertNull($mapObject->get(self::$mapKey[1]));
     $this->assertNull($mapObject->get(self::$mapKey[2]));
     $this->assertNull($mapObject->get(self::$mapKey[3]));
 }
Exemple #2
0
use Naucon\Utility\Map;
class FooString
{
    protected $value = null;
    public function __construct($value)
    {
        $this->value = $value;
    }
    public function __toString()
    {
        return $this->value;
    }
}
// init map
$mapObject = new Map();
// mapping pair 1
$mapKey[] = 'KeyA';
$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]);