Doctrine\Tests\OXM\Entities\User::addContact PHP Method

addContact() public method

public addContact ( CustomerContact $contact )
$contact CustomerContact
    public function addContact(CustomerContact $contact)
    {
        $this->contacts[] = $contact;
    }

Usage Example

Beispiel #1
0
 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('*****@*****.**'));
     $user->addContact(new CustomerContact('*****@*****.**'));
     $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()));
 }