SAML2\XML\mdui\UIInfoTest::testMarshalling PHP Method

testMarshalling() public method

Test creating a basic UIInfo element.
public testMarshalling ( )
    public function testMarshalling()
    {
        $uiinfo = new UIInfo();
        $uiinfo->DisplayName = array("nl" => "Voorbeeld", "en" => "Example");
        $uiinfo->Description = array("nl" => "Omschrijving", "en" => "Description");
        $uiinfo->InformationURL = array("nl" => "https://voorbeeld.nl/", "en" => "https://example.org");
        $uiinfo->PrivacyStatementURL = array("nl" => "https://voorbeeld.nl/privacy", "en" => "https://example.org/privacy");
        $document = DOMDocumentFactory::fromString('<root />');
        $xml = $uiinfo->toXML($document->firstChild);
        $infoElements = Utils::xpQuery($xml, '/root/*[local-name()=\'UIInfo\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:ui\']');
        $this->assertCount(1, $infoElements);
        $infoElement = $infoElements[0];
        $displaynameElements = Utils::xpQuery($infoElement, './*[local-name()=\'DisplayName\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:ui\']');
        $this->assertCount(2, $displaynameElements);
        $this->assertEquals("Voorbeeld", $displaynameElements[0]->textContent);
        $this->assertEquals("Example", $displaynameElements[1]->textContent);
        $this->assertEquals("nl", $displaynameElements[0]->getAttribute("xml:lang"));
        $this->assertEquals("en", $displaynameElements[1]->getAttribute("xml:lang"));
        $descriptionElements = Utils::xpQuery($infoElement, './*[local-name()=\'Description\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:ui\']');
        $this->assertCount(2, $descriptionElements);
        $this->assertEquals("Omschrijving", $descriptionElements[0]->textContent);
        $this->assertEquals("Description", $descriptionElements[1]->textContent);
        $this->assertEquals("nl", $descriptionElements[0]->getAttribute("xml:lang"));
        $this->assertEquals("en", $descriptionElements[1]->getAttribute("xml:lang"));
        $infourlElements = Utils::xpQuery($infoElement, './*[local-name()=\'InformationURL\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:ui\']');
        $this->assertCount(2, $infourlElements);
        $this->assertEquals("https://voorbeeld.nl/", $infourlElements[0]->textContent);
        $this->assertEquals("https://example.org", $infourlElements[1]->textContent);
        $this->assertEquals("nl", $infourlElements[0]->getAttribute("xml:lang"));
        $this->assertEquals("en", $infourlElements[1]->getAttribute("xml:lang"));
        $privurlElements = Utils::xpQuery($infoElement, './*[local-name()=\'PrivacyStatementURL\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:ui\']');
        $this->assertCount(2, $privurlElements);
        $this->assertEquals("https://voorbeeld.nl/privacy", $privurlElements[0]->textContent);
        $this->assertEquals("https://example.org/privacy", $privurlElements[1]->textContent);
        $this->assertEquals("nl", $privurlElements[0]->getAttribute("xml:lang"));
        $this->assertEquals("en", $privurlElements[1]->getAttribute("xml:lang"));
    }