コード例 #1
0
 public function test__serializer()
 {
     $esd = new EntitiesDescriptor();
     $esd->addItem(new EntityDescriptor('ed1'));
     $esd->addItem(new EntityDescriptor('ed2'));
     $esd2 = new EntitiesDescriptor();
     $esd2->addItem(new EntityDescriptor('ed3'));
     $esd->addItem($esd2);
     $ctx = new SerializationContext();
     $esd->serialize($ctx->getDocument(), $ctx);
     $xpath = new \DOMXPath($ctx->getDocument());
     $xpath->registerNamespace('md', SamlConstants::NS_METADATA);
     $this->assertEquals(1, $xpath->query('/md:EntitiesDescriptor')->length);
     $this->assertEquals(2, $xpath->query('/md:EntitiesDescriptor/md:EntityDescriptor')->length);
     $this->assertEquals(1, $xpath->query('/md:EntitiesDescriptor/md:EntityDescriptor[@entityID="ed1"]')->length);
     $this->assertEquals(1, $xpath->query('/md:EntitiesDescriptor/md:EntityDescriptor[@entityID="ed2"]')->length);
     $this->assertEquals(1, $xpath->query('/md:EntitiesDescriptor/md:EntitiesDescriptor')->length);
     $this->assertEquals(1, $xpath->query('/md:EntitiesDescriptor/md:EntitiesDescriptor/md:EntityDescriptor[@entityID="ed3"]')->length);
 }