Doctrine\Tests\OXM\Marshaller\CollectionsTest::collectionWrapsXmlElement PHP Метод

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

    public function collectionWrapsXmlElement()
    {
        $wrapperForElement = new WrapperForElement();
        $element = new Element();
        $element->attribute = 'blue';
        $element2 = new Element();
        $element2->attribute = 'red';
        $wrapperForElement->attributes = array($element, $element2);
        $xml = $this->marshaller->marshalToString($wrapperForElement);
        $this->assertXmlStringEqualsXmlString('<?xml version="1.0" encoding="UTF-8"?>
        <wrapper-for-element>
            <foo>
                <element>
                    <attribute>blue</attribute>
                </element>
                <element>
                    <attribute>red</attribute>
                </element>
            </foo>
        </wrapper-for-element>', $xml);
        $otherWrapperForElement = $this->marshaller->unmarshalFromString($xml);
        $this->assertEquals(2, count($otherWrapperForElement->attributes));
        $this->assertContains('blue', $otherWrapperForElement->attributes[0]->attribute);
        $this->assertContains('red', $otherWrapperForElement->attributes[1]->attribute);
    }