SAML2\XML\mdrpi\PublicationInfoTest::testMarshalling PHP Метод

testMarshalling() публичный Метод

public testMarshalling ( )
    public function testMarshalling()
    {
        $publicationInfo = new PublicationInfo();
        $publicationInfo->publisher = 'TestPublisher';
        $publicationInfo->creationInstant = 1234567890;
        $publicationInfo->publicationId = 'PublicationIdValue';
        $publicationInfo->UsagePolicy = array('en' => 'http://EnglishUsagePolicy', 'no' => 'http://NorwegianUsagePolicy');
        $document = DOMDocumentFactory::fromString('<root />');
        $xml = $publicationInfo->toXML($document->firstChild);
        $publicationInfoElements = Utils::xpQuery($xml, '/root/*[local-name()=\'PublicationInfo\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:rpi\']');
        $this->assertCount(1, $publicationInfoElements);
        $publicationInfoElement = $publicationInfoElements[0];
        $this->assertEquals('TestPublisher', $publicationInfoElement->getAttribute("publisher"));
        $this->assertEquals('2009-02-13T23:31:30Z', $publicationInfoElement->getAttribute("creationInstant"));
        $this->assertEquals('PublicationIdValue', $publicationInfoElement->getAttribute("publicationId"));
        $usagePolicyElements = Utils::xpQuery($publicationInfoElement, './*[local-name()=\'UsagePolicy\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:rpi\']');
        $this->assertCount(2, $usagePolicyElements);
        $this->assertEquals('en', $usagePolicyElements[0]->getAttributeNS("http://www.w3.org/XML/1998/namespace", "lang"));
        $this->assertEquals('http://EnglishUsagePolicy', $usagePolicyElements[0]->textContent);
        $this->assertEquals('no', $usagePolicyElements[1]->getAttributeNS("http://www.w3.org/XML/1998/namespace", "lang"));
        $this->assertEquals('http://NorwegianUsagePolicy', $usagePolicyElements[1]->textContent);
    }