Ejemplo n.º 1
0
 public function testMergeVersionable()
 {
     $versionableArticle = new FullVersionableArticle();
     $versionableArticle->setText('very interesting content');
     $versionableArticle->author = 'greg0ire';
     $versionableArticle->topic = 'whatever';
     $versionableArticle->id = '/functional/whatever';
     $versionableArticle->versionName = 'v1';
     $this->dm->persist($versionableArticle);
     $this->dm->flush();
     $this->dm->clear();
     $versionableArticle->versionName = 'v2';
     $mergedVersionableArticle = $this->dm->merge($versionableArticle);
     $this->assertEquals('v2', $mergedVersionableArticle->versionName);
 }
Ejemplo n.º 2
0
 public function testMergeWithChildren()
 {
     $user = new CmsUser();
     $user->username = "******";
     $user->name = "Benjamin";
     $teamuser = new CmsTeamUser();
     $teamuser->username = "******";
     $teamuser->name = "Jonathan Wage";
     $teamuser->parent = $user;
     $this->dm->persist($user);
     $this->dm->persist($teamuser);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->find(null, '/functional/beberlei');
     $this->assertCount(1, $user->children);
     $mergableUser = new CmsUser();
     $mergableUser->username = "******";
     $mergableUser->name = "John Galt";
     $mergableUser->id = $user->id;
     $mergedUser = $this->dm->merge($mergableUser);
     $this->assertSame($mergedUser, $user);
     $this->assertEquals("jgalt", $mergedUser->username);
     $this->assertCount(1, $mergedUser->children);
     $this->dm->flush();
     $mergedUser->children->count();
     $mergableUser = new CmsUser();
     $mergableUser->id = $user->id;
     $mergableUser->username = '******';
     $mergedUser = $this->dm->merge($mergableUser);
     $this->assertSame($mergedUser, $user);
     $this->assertEquals('dbu', $mergedUser->username);
     $this->assertNull($mergedUser->name);
     $this->assertCount(1, $mergedUser->children);
     $this->dm->flush();
     $mergedUser = $this->dm->find(null, $mergedUser->id);
     $this->assertCount(1, $mergedUser->children);
 }