3 namespace Doctrine\Tests\ORM\Functional\Ticket;
5 use Doctrine\Common\Collections\ArrayCollection;
6 use Doctrine\Tests\Models\CMS\CmsUser;
7 use Doctrine\Tests\Models\CMS\CmsArticle;
8 use Doctrine\Tests\Models\CMS\CmsAddress;
10 require_once __DIR__ . '/../../../TestInit.php';
12 class DDC748Test extends \Doctrine\Tests\OrmFunctionalTestCase
14 protected function setUp()
16 $this->useModelSet('cms');
20 public function testRefreshWithManyToOne()
22 $user = new CmsUser();
23 $user->name = "beberlei";
24 $user->status = "active";
25 $user->username = "beberlei";
27 $article = new CmsArticle();
28 $article->setAuthor($user);
29 $article->text = "foo";
30 $article->topic = "bar";
32 $this->_em->persist($user);
33 $this->_em->persist($article);
36 $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles);
37 $this->_em->refresh($article);
38 $this->assertTrue($article !== $user->articles, "The article should not be replaced on the inverse side of the relation.");
39 $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles);
42 public function testRefreshOneToOne()
44 $user = new CmsUser();
45 $user->name = "beberlei";
46 $user->status = "active";
47 $user->username = "beberlei";
49 $address = new CmsAddress();
50 $address->city = "Bonn";
51 $address->country = "Germany";
52 $address->street = "A street";
53 $address->zip = 12345;
54 $address->setUser($user);
56 $this->_em->persist($user);
57 $this->_em->persist($address);
60 $this->_em->refresh($address);
61 $this->assertSame($user, $address->user);
62 $this->assertSame($user->address, $address);