public function testSetter() { $map = new Map(["a" => 1, "b" => 2, "c" => 3]); $map["d"] = 4; $map->c = 5; $map->set("a", 6); $this->assertEquals(4, $map->count()); $this->assertEquals(4, $map->get("d")); $this->assertEquals(5, $map->get("c")); $this->assertEquals(6, $map->get("a")); }
/** * {@inheritDoc} * @return $this */ public function indexBy($callback) { $group = new Map(); foreach ($this as $value) { $key = $callback($value); $group->set($key, $value); } return $group; }
public function testToValuesArray() { $dictionary = new Map(); $dictionary->set('key1', 'value1')->set('key2', 'value2'); $expected = ['value1', 'value2']; $this->assertEquals($expected, $dictionary->toValuesArray()); }