예제 #1
0
파일: TraitTest.php 프로젝트: graste/params
 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());
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
 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]);
 }