protected function unmarshall(DOMElement $element)
 {
     $object = new ItemSubset();
     if (($sectionIdentifier = static::getDOMElementAttributeAs($element, 'sectionIdentifier')) !== null) {
         $object->setSectionIdentifier($sectionIdentifier);
     }
     if (($includeCategories = static::getDOMElementAttributeAs($element, 'includeCategory')) !== null) {
         $includeCategories = new IdentifierCollection(explode(" ", $includeCategories));
         $object->setIncludeCategories($includeCategories);
     }
     if (($excludeCategories = static::getDOMElementAttributeAs($element, 'excludeCategory')) !== null) {
         $excludeCategories = new IdentifierCollection(explode(" ", $excludeCategories));
         $object->setExcludeCategories($excludeCategories);
     }
     return $object;
 }
Exemplo n.º 2
0
 public function testMarshallIncludeExcludeCategories()
 {
     $sectionIdentifier = 'mySection1';
     $includeCategories = new IdentifierCollection(array('cat1', 'cat2'));
     $excludeCategories = new IdentifierCollection(array('cat3', 'cat4'));
     $component = new ItemSubset();
     $component->setSectionIdentifier($sectionIdentifier);
     $component->setIncludeCategories($includeCategories);
     $component->setExcludeCategories($excludeCategories);
     $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component);
     $element = $marshaller->marshall($component);
     $this->assertInstanceOf('\\DOMElement', $element);
     $this->assertEquals('itemSubset', $element->nodeName);
     $this->assertEquals($sectionIdentifier, $element->getAttribute('sectionIdentifier'));
     $this->assertEquals(implode(" ", $includeCategories->getArrayCopy()), $element->getAttribute('includeCategory'));
     $this->assertEquals(implode(" ", $excludeCategories->getArrayCopy()), $element->getAttribute('excludeCategory'));
 }