Beispiel #1
0
 private function loadFixtures()
 {
     $u1 = new CmsUser();
     $u2 = new CmsUser();
     $u3 = new CmsUser();
     $u1->setEmail(new CmsEmail());
     $u1->setAddress(new CmsAddress());
     $u1->addPhonenumber(new CmsPhonenumber());
     $u2->setEmail(new CmsEmail());
     $u2->setAddress(new CmsAddress());
     $u2->addPhonenumber(new CmsPhonenumber());
     $u2->addPhonenumber(new CmsPhonenumber());
     $u3->setEmail(new CmsEmail());
     $u3->setAddress(new CmsAddress());
     $u3->addPhonenumber(new CmsPhonenumber());
     $u3->addPhonenumber(new CmsPhonenumber());
     $u3->addPhonenumber(new CmsPhonenumber());
     $u1->name = 'Test 1';
     $u1->username = '******';
     $u1->status = 'developer';
     $u1->email->email = '*****@*****.**';
     $u1->address->zip = '111111111';
     $u1->address->city = 'Some City 1';
     $u1->address->country = 'Some Country 2';
     $u1->phonenumbers[0]->phonenumber = "(11) 1111-1111";
     $u2->name = 'Test 2';
     $u2->username = '******';
     $u2->status = 'developer';
     $u2->email->email = '*****@*****.**';
     $u2->address->zip = '222222222';
     $u2->address->city = 'Some City 2';
     $u2->address->country = 'Some Country 2';
     $u2->phonenumbers[0]->phonenumber = "(22) 1111-1111";
     $u2->phonenumbers[1]->phonenumber = "(22) 2222-2222";
     $u3->name = 'Test 3';
     $u3->username = '******';
     $u3->status = 'developer';
     $u3->email->email = '*****@*****.**';
     $u3->address->zip = '33333333';
     $u3->address->city = 'Some City 3';
     $u3->address->country = 'Some Country 3';
     $u3->phonenumbers[0]->phonenumber = "(33) 1111-1111";
     $u3->phonenumbers[1]->phonenumber = "(33) 2222-2222";
     $u3->phonenumbers[2]->phonenumber = "(33) 3333-3333";
     $this->_em->persist($u1);
     $this->_em->persist($u2);
     $this->_em->persist($u3);
     $this->_em->flush();
     $this->_em->clear();
     $this->fixtures = array($u1, $u2, $u3);
 }
Beispiel #2
0
 public function testGivenOrphanRemovalOneToOne_WhenReplacing_ThenNoUniqueConstraintError()
 {
     $user = new CmsUser();
     $user->name = "Benjamin";
     $user->username = "******";
     $user->status = "something";
     $user->setEmail($email = new CmsEmail());
     $email->setEmail("*****@*****.**");
     $this->_em->persist($user);
     $this->_em->flush();
     $this->assertTrue($this->_em->contains($email));
     $user->setEmail($newEmail = new CmsEmail());
     $newEmail->setEmail("*****@*****.**");
     $this->_em->flush();
     $this->assertFalse($this->_em->contains($email));
 }
 public function testOrphanRemovalWhenUnlink()
 {
     $user = new CmsUser();
     $user->status = 'dev';
     $user->username = '******';
     $user->name = 'Bejamin Eberlei';
     $email = new CmsEmail();
     $email->email = '*****@*****.**';
     $user->setEmail($email);
     $this->_em->persist($user);
     $this->_em->flush();
     $userId = $user->getId();
     $this->_em->clear();
     $user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $userId);
     $user->setEmail(null);
     $this->_em->persist($user);
     $this->_em->flush();
     $this->_em->clear();
     $query = $this->_em->createQuery('SELECT e FROM Doctrine\\Tests\\Models\\CMS\\CmsEmail e');
     $result = $query->getResult();
     $this->assertEquals(0, count($result), 'CmsEmail should be removed by orphanRemoval');
 }
Beispiel #4
0
 /**
  * @group DDC-1663
  */
 public function testBasicNativeNamedQueryWithResultClass()
 {
     $user = new CmsUser();
     $user->name = 'Fabio B. Silva';
     $user->username = '******';
     $user->status = 'dev';
     $email = new CmsEmail();
     $email->email = '*****@*****.**';
     $user->setEmail($email);
     $this->_em->clear();
     $this->_em->persist($user);
     $this->_em->flush();
     $this->_em->clear();
     $repository = $this->_em->getRepository('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $result = $repository->createNativeNamedQuery('fetchIdAndUsernameWithResultClass')->setParameter(1, 'FabioBatSilva')->getResult();
     $this->assertEquals(1, count($result));
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\CMS\\CmsUser', $result[0]);
     $this->assertNull($result[0]->name);
     $this->assertNull($result[0]->email);
     $this->assertEquals($user->id, $result[0]->id);
     $this->assertEquals('FabioBatSilva', $result[0]->username);
     $this->_em->clear();
     $result = $repository->createNativeNamedQuery('fetchAllColumns')->setParameter(1, 'FabioBatSilva')->getResult();
     $this->assertEquals(1, count($result));
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\CMS\\CmsUser', $result[0]);
     $this->assertEquals($user->id, $result[0]->id);
     $this->assertEquals('Fabio B. Silva', $result[0]->name);
     $this->assertEquals('FabioBatSilva', $result[0]->username);
     $this->assertEquals('dev', $result[0]->status);
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\CMS\\CmsEmail', $result[0]->email);
 }
 public function loadFixtureUserEmail()
 {
     $user1 = new CmsUser();
     $user2 = new CmsUser();
     $user3 = new CmsUser();
     $email1 = new CmsEmail();
     $email2 = new CmsEmail();
     $email3 = new CmsEmail();
     $user1->name = 'Test 1';
     $user1->username = '******';
     $user1->status = 'active';
     $user2->name = 'Test 2';
     $user2->username = '******';
     $user2->status = 'active';
     $user3->name = 'Test 3';
     $user3->username = '******';
     $user3->status = 'active';
     $email1->email = '*****@*****.**';
     $email2->email = '*****@*****.**';
     $email3->email = '*****@*****.**';
     $user1->setEmail($email1);
     $user2->setEmail($email2);
     $user3->setEmail($email3);
     $this->_em->persist($user1);
     $this->_em->persist($user2);
     $this->_em->persist($user3);
     $this->_em->persist($email1);
     $this->_em->persist($email2);
     $this->_em->persist($email3);
     $this->_em->flush();
     $this->_em->clear();
     return array($user1, $user2, $user3);
 }
 private function loadFixture()
 {
     $user = new CmsUser();
     $user->name = 'Roman';
     $user->username = '******';
     $user->status = 'developer';
     $address = new CmsAddress();
     $address->country = 'Germany';
     $address->city = 'Berlin';
     $address->zip = '12345';
     $user->setAddress($address);
     $email = new CmsEmail();
     $email->setEmail('*****@*****.**');
     $user->setEmail($email);
     $ph1 = new CmsPhonenumber();
     $ph1->phonenumber = "0301234";
     $ph2 = new CmsPhonenumber();
     $ph2->phonenumber = "987654321";
     $user->addPhonenumber($ph1);
     $user->addPhonenumber($ph2);
     $this->_em->persist($user);
     $this->_em->flush();
     $this->userId = $user->getId();
     $this->_em->clear();
 }