public function testOptionsAreLostWhenCopyingParamsViaAddParams() { $p = new TraitTester(); $custom_iterator_class = 'Params\\Tests\\Fixtures\\CustomArrayIterator'; $a = new ConfigurableArrayObject(['foo' => 'bar'], [ConfigurableArrayObject::OPTION_ITERATOR => $custom_iterator_class]); $this->assertEquals('bar', $a['foo']); $this->assertInstanceOf($custom_iterator_class, $a->getIterator()); $this->assertInstanceOf('\\Params\\Tests\\Fixtures\\TraitTester', $p->setParameters($a)); $this->assertEquals('bar', $p->getParameter('foo')); $this->assertNotInstanceOf($custom_iterator_class, $p->getParameters()->getIterator()); $this->assertInstanceOf('\\Params\\Tests\\Fixtures\\TraitTester', $p->setOptions($a)); $this->assertEquals('bar', $p->getOption('foo')); $this->assertNotInstanceOf($custom_iterator_class, $p->getOptions()->getIterator()); $this->assertInstanceOf('\\Params\\Tests\\Fixtures\\TraitTester', $p->setSettings($a)); $this->assertEquals('bar', $p->getSetting('foo')); $this->assertNotInstanceOf($custom_iterator_class, $p->getSettings()->getIterator()); }
/** * Create a new instance with the given data as initial value set. * * The 'mutable' option will be set to false even if provided as true. * * @param array $data initial data * @param array $options */ public function __construct(array $data = [], array $options = []) { $options[self::OPTION_MUTABLE] = false; parent::__construct($data, $options); }
public function testAppendNumericIndizes() { $params = new ConfigurableArrayObject($this->getExampleValues()); $params->append('by'); $params->set(1, 'ref'); $params[] = 'srsly'; $this->assertEquals('by', $params->get(0)); $this->assertEquals('ref', $params->get(1)); $this->assertEquals('srsly', $params[2]); }