SAML2\XML\mdrpi\RegistrationInfoTest::testMarshalling PHP Method

testMarshalling() public method

public testMarshalling ( )
    public function testMarshalling()
    {
        $registrationInfo = new RegistrationInfo();
        $registrationInfo->registrationAuthority = 'https://ExampleAuthority';
        $registrationInfo->registrationInstant = 1234567890;
        $registrationInfo->RegistrationPolicy = array('en' => 'http://EnglishRegistrationPolicy', 'nl' => 'https://DutchRegistratiebeleid');
        $document = DOMDocumentFactory::fromString('<root />');
        $xml = $registrationInfo->toXML($document->firstChild);
        $registrationInfoElements = Utils::xpQuery($xml, '/root/*[local-name()=\'RegistrationInfo\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:rpi\']');
        $this->assertCount(1, $registrationInfoElements);
        $registrationInfoElement = $registrationInfoElements[0];
        $this->assertEquals('https://ExampleAuthority', $registrationInfoElement->getAttribute("registrationAuthority"));
        $this->assertEquals('2009-02-13T23:31:30Z', $registrationInfoElement->getAttribute("registrationInstant"));
        $usagePolicyElements = Utils::xpQuery($registrationInfoElement, './*[local-name()=\'RegistrationPolicy\' 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://EnglishRegistrationPolicy', $usagePolicyElements[0]->textContent);
        $this->assertEquals('nl', $usagePolicyElements[1]->getAttributeNS("http://www.w3.org/XML/1998/namespace", "lang"));
        $this->assertEquals('https://DutchRegistratiebeleid', $usagePolicyElements[1]->textContent);
    }