Esempio n. 1
0
 /**
  * @test
  */
 public function unserializedBagIsCopyOfSerializedBag()
 {
     $container = new BagContainer();
     $container->add('someName1', 'someValue1');
     $container->add('someName2', array('someKey' => 'someValue'));
     $unserializedContainer = unserialize(serialize($container));
     $expectedAttributes = array('someName1' => 'someValue1', 'someName2' => array('someKey' => 'someValue'));
     $this->assertEquals($expectedAttributes, $unserializedContainer->getAll());
 }
Esempio n. 2
0
 public function addConstraintsFromAttributes(BagContainer $constraint, \XMLReader $reader, array $ignoredAttributes = array(self::ATTRIBUTE_CLASS))
 {
     while ($reader->moveToNextAttribute()) {
         $attributes = $this->getAttributesFromXmlAttribute($reader);
         foreach ($attributes as $name => $value) {
             if (!in_array($name, $ignoredAttributes)) {
                 if ($complexAttributeName = $this->getComplexAttributeName($name)) {
                     $propertyName = substr($name, strlen($complexAttributeName) + 1);
                     $constraint->add($complexAttributeName, array('name' => $complexAttributeName, $propertyName => $value));
                 } else {
                     $constraint->add($name, $value);
                 }
             }
         }
     }
 }