Doctrine\Tests\OXM\Marshaller\MarshallerTest::testFirstClassMarshaller PHP Method

testFirstClassMarshaller() public method

    public function testFirstClassMarshaller()
    {
        $user = new User();
        $user->setFirstNameNickname('Malcolm');
        $user->setLastName('Reynolds');
        $user->setAddress(new Address('123 Waverly Way', 'New Haven', 'Insanity'));
        $user->addContact(new CustomerContact('[email protected]'));
        $user->addContact(new CustomerContact('[email protected]'));
        $xml = $this->marshaller->marshalToString($user);
        $dom = new \DOMDocument('1.0');
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;
        $dom->loadXML($xml);
        //        print_r($dom->saveXML());
        $otherUser = $this->marshaller->unmarshalFromString($xml);
        //        print_r($otherUser);
        $this->assertInstanceOf('Doctrine\\Tests\\OXM\\Entities\\User', $otherUser);
        $this->assertEquals('Malcolm', $otherUser->getFirstNameNickname());
        $this->assertEquals('Reynolds', $otherUser->getLastName());
        $this->assertEquals('123 Waverly Way', $otherUser->getAddress()->getStreet());
        $this->assertEquals('New Haven', $otherUser->getAddress()->getCity());
        $this->assertEquals('Insanity', $otherUser->getAddress()->getState());
        $this->assertEquals(2, count($otherUser->getContacts()));
    }