public function testLinkTo() { $map = new \Bonder\Collections\Map(); $map->set('3', 'three'); $this->assertTrue($map->containsKey('3')); $array = array('7' => 'seven', '19' => 'nineteen', '31' => 'thirty-one'); $map->linkTo($array); $this->assertFalse($map->containsKey('3')); $this->assertEquals(3, $map->size()); $map->remove('31'); $this->assertEquals(2, $map->size()); unset($array['19']); $this->assertEquals(1, $map->size()); $this->assertTrue($map->isLinkedTo($array)); }
/** * Returns a new Map, linked to the array given. * * @param array $array the array to link to. * @return \Bonder\Collections\Map the map. */ public static function fromReference(array &$array) { $map = new \Bonder\Collections\Map(); $map->linkTo($array); return $map; }