/**
  * Convert this element to XML.
  *
  * @param  DOMElement $parent The parent element we should append this element to.
  * @return DOMElement This element, as XML.
  */
 public function toXML(DOMElement $parent)
 {
     assert('is_string($this->Method)');
     assert('is_null($this->NameID) || $this->NameID instanceof SAML2_XML_saml_NameID');
     assert('is_null($this->SubjectConfirmationData) || $this->SubjectConfirmationData instanceof SAML2_XML_saml_SubjectConfirmationData');
     $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:SubjectConfirmation');
     $parent->appendChild($e);
     $e->setAttribute('Method', $this->Method);
     if (isset($this->NameID)) {
         $this->NameID->toXML($e);
     }
     if (isset($this->SubjectConfirmationData)) {
         $this->SubjectConfirmationData->toXML($e);
     }
     return $e;
 }
Beispiel #2
0
 public function testMarshalling()
 {
     $nameId = new SAML2_XML_saml_NameID();
     $nameId->NameQualifier = 'TheNameQualifier';
     $nameId->SPNameQualifier = 'TheSPNameQualifier';
     $nameId->Format = 'TheFormat';
     $nameId->SPProvidedID = 'TheSPProvidedID';
     $nameId->value = 'TheNameIDValue';
     $nameIdElement = $nameId->toXML();
     $nameIdElements = SAML2_Utils::xpQuery($nameIdElement, '/saml_assertion:NameID');
     $this->assertCount(1, $nameIdElements);
     $nameIdElement = $nameIdElements[0];
     $this->assertEquals('TheNameQualifier', $nameIdElement->getAttribute("NameQualifier"));
     $this->assertEquals('TheSPNameQualifier', $nameIdElement->getAttribute("SPNameQualifier"));
     $this->assertEquals('TheFormat', $nameIdElement->getAttribute("Format"));
     $this->assertEquals('TheSPProvidedID', $nameIdElement->getAttribute("SPProvidedID"));
     $this->assertEquals('TheNameIDValue', $nameIdElement->textContent);
 }