コード例 #1
0
ファイル: AttributeValueTest.php プロジェクト: madmatt/saml2
    /**
     * Verifies that we can create an AttributeValue from a DOMElement.
     */
    public function testCreateAttributeFromDOMElement()
    {
        $attribute = new Attribute();
        $attribute->Name = 'TheName';
        $attribute->NameFormat = 'TheNameFormat';
        $attribute->FriendlyName = 'TheFriendlyName';
        $element = new \DOMDocument();
        $element->loadXML(<<<ATTRIBUTEVALUE
<NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">urn:collab:person:surftest.nl:example</NameID>
ATTRIBUTEVALUE
);
        $attribute->AttributeValue = array(new AttributeValue($element->documentElement));
        $document = DOMDocumentFactory::fromString('<root />');
        $returnedStructure = $attribute->toXML($document->firstChild);
        $expectedStructureDocument = new \DOMDocument();
        $expectedStructureDocument->loadXML(<<<ATTRIBUTEXML
<saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
  Name="TheName" NameFormat="TheNameFormat" FriendlyName="TheFriendlyName">
  <saml:AttributeValue>
    <NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">urn:collab:person:surftest.nl:example</NameID>
  </saml:AttributeValue>
</saml:Attribute>
ATTRIBUTEXML
);
        $expectedStructure = $expectedStructureDocument->documentElement;
        $this->assertEqualXMLStructure($expectedStructure, $returnedStructure);
        $this->assertEquals("urn:collab:person:surftest.nl:example", $attribute->AttributeValue[0]->getString());
    }
コード例 #2
0
ファイル: ChunkTest.php プロジェクト: simplesamlphp/saml2
 /**
  * Make a new Chunk object to test with
  */
 public function setUp()
 {
     $attribute = new Attribute();
     $attribute->Name = 'TheName';
     $attribute->NameFormat = 'TheNameFormat';
     $attribute->FriendlyName = 'TheFriendlyName';
     $attribute->AttributeValue = array(new AttributeValue('FirstValue'), new AttributeValue('SecondValue'));
     $document = DOMDocumentFactory::fromString('<root />');
     $attributeElement = $attribute->toXML($document->firstChild);
     $this->chunk = new Chunk($attributeElement);
 }
コード例 #3
0
ファイル: AttributeTest.php プロジェクト: SysBind/saml2
 public function testMarshalling()
 {
     $attribute = new Attribute();
     $attribute->Name = 'TheName';
     $attribute->NameFormat = 'TheNameFormat';
     $attribute->FriendlyName = 'TheFriendlyName';
     $attribute->AttributeValue = array(new AttributeValue('FirstValue'), new AttributeValue('SecondValue'));
     $document = DOMDocumentFactory::fromString('<root />');
     $attributeElement = $attribute->toXML($document->firstChild);
     $attributeElements = Utils::xpQuery($attributeElement, '/root/saml_assertion:Attribute');
     $this->assertCount(1, $attributeElements);
     $attributeElement = $attributeElements[0];
     $this->assertEquals('TheName', $attributeElement->getAttribute('Name'));
     $this->assertEquals('TheNameFormat', $attributeElement->getAttribute('NameFormat'));
     $this->assertEquals('TheFriendlyName', $attributeElement->getAttribute('FriendlyName'));
 }
コード例 #4
0
ファイル: RequestedAttribute.php プロジェクト: SysBind/saml2
 /**
  * Initialize an RequestedAttribute.
  *
  * @param \DOMElement|null $xml The XML element we should load.
  */
 public function __construct(\DOMElement $xml = null)
 {
     parent::__construct($xml);
     if ($xml === null) {
         return;
     }
     $this->isRequired = Utils::parseBoolean($xml, 'isRequired', null);
 }