public function setUp()
 {
     $user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user1->username = "******";
     $user1->status = "active";
     $user1->name = "Benjamin";
     $user2 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user2->username = "******";
     $user2->status = "active";
     $user2->name = "Lukas";
     $article1 = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article1->text = "Foo";
     $article1->topic = "Foo";
     $article1->setAuthor($user1);
     $article2 = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article2->text = "Foo";
     $article2->topic = "Foo";
     $article2->setAuthor($user1);
     $this->dm = $this->createDocumentManager();
     $this->dm->persist($user1);
     $this->dm->persist($user2);
     $this->dm->persist($article1);
     $this->dm->persist($article2);
     $this->dm->flush();
     $this->dm->clear();
     $this->articleIds = array($article1->id, $article2->id);
     $this->userIds = array($user1->id, $user2->id);
 }
 private function loadFixture()
 {
     $user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user1->username = "******";
     $user1->name = "Benjamin";
     $user1->status = "active";
     $user2 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user2->username = "******";
     $user2->name = "Jonathan";
     $user2->status = "active";
     $user3 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user3->username = "******";
     $user3->name = "Roman";
     $user3->status = "active";
     $user4 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user4->username = "******";
     $user4->name = "Guilherme";
     $user4->status = "active";
     $this->_em->persist($user1);
     $this->_em->persist($user2);
     $this->_em->persist($user3);
     $this->_em->persist($user4);
     $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group1->name = "Test1";
     $group2 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group2->name = "Test2";
     $group3 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group3->name = "Test3";
     $user1->addGroup($group1);
     $user1->addGroup($group2);
     $user1->addGroup($group3);
     $user2->addGroup($group1);
     $user3->addGroup($group1);
     $user4->addGroup($group1);
     $this->_em->persist($group1);
     $this->_em->persist($group2);
     $this->_em->persist($group3);
     $article1 = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article1->topic = "Test";
     $article1->text = "Test";
     $article1->setAuthor($user1);
     $article2 = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article2->topic = "Test";
     $article2->text = "Test";
     $article2->setAuthor($user1);
     $this->_em->persist($article1);
     $this->_em->persist($article2);
     $this->_em->flush();
     $this->_em->clear();
     $this->articleId = $article1->id;
     $this->userId = $user1->getId();
     $this->groupId = $group1->id;
 }
 public function testFlushDoesNotIssueUnnecessaryUpdates()
 {
     $user = new CmsUser();
     $user->name = 'Guilherme';
     $user->username = '******';
     $user->status = 'developer';
     $address = new CmsAddress();
     $address->country = 'Germany';
     $address->city = 'Berlin';
     $address->zip = '12345';
     $address->user = $user;
     $user->address = $address;
     $article = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article->text = "Lorem ipsum dolor sunt.";
     $article->topic = "A Test Article!";
     $article->setAuthor($user);
     $this->_em->persist($article);
     $this->_em->persist($user);
     //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
     $this->_em->flush();
     $this->_em->clear();
     $query = $this->_em->createQuery('select u,a,ad from Doctrine\\Tests\\Models\\CMS\\CmsUser u join u.articles a join u.address ad');
     $user2 = $query->getSingleResult();
     $this->assertEquals(1, count($user2->articles));
     $this->assertTrue($user2->address instanceof CmsAddress);
     $oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger();
     $debugStack = new \Doctrine\DBAL\Logging\DebugStack();
     $this->_em->getConnection()->getConfiguration()->setSQLLogger($debugStack);
     $this->_em->flush();
     $this->assertEquals(0, count($debugStack->queries));
     $this->_em->getConnection()->getConfiguration()->setSQLLogger($oldLogger);
 }
Ejemplo n.º 4
0
 private function loadFixture()
 {
     $user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user1->username = "******";
     $user1->name = "Benjamin";
     $user1->status = "active";
     $user2 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user2->username = "******";
     $user2->name = "Jonathan";
     $user2->status = "active";
     $user3 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user3->username = "******";
     $user3->name = "Roman";
     $user3->status = "active";
     $user4 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user4->username = "******";
     $user4->name = "Guilherme";
     $user4->status = "active";
     $this->_em->persist($user1);
     $this->_em->persist($user2);
     $this->_em->persist($user3);
     $this->_em->persist($user4);
     $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group1->name = "Test1";
     $group2 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group2->name = "Test2";
     $group3 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group3->name = "Test3";
     $user1->addGroup($group1);
     $user1->addGroup($group2);
     $user1->addGroup($group3);
     $user2->addGroup($group1);
     $user3->addGroup($group1);
     $user4->addGroup($group1);
     $this->_em->persist($group1);
     $this->_em->persist($group2);
     $this->_em->persist($group3);
     $article1 = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article1->topic = "Test1";
     $article1->text = "Test1";
     $article1->setAuthor($user1);
     $article2 = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article2->topic = "Test2";
     $article2->text = "Test2";
     $article2->setAuthor($user1);
     $this->_em->persist($article1);
     $this->_em->persist($article2);
     $phonenumber1 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber();
     $phonenumber1->phonenumber = '12345';
     $phonenumber2 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber();
     $phonenumber2->phonenumber = '67890';
     $this->_em->persist($phonenumber1);
     $this->_em->persist($phonenumber2);
     $user1->addPhonenumber($phonenumber1);
     // DDC-2504
     $otherClass = new DDC2504OtherClass();
     $childClass1 = new DDC2504ChildClass();
     $childClass2 = new DDC2504ChildClass();
     $childClass1->other = $otherClass;
     $childClass2->other = $otherClass;
     $otherClass->childClasses[] = $childClass1;
     $otherClass->childClasses[] = $childClass2;
     $this->_em->persist($childClass1);
     $this->_em->persist($childClass2);
     $this->_em->persist($otherClass);
     $this->_em->flush();
     $this->_em->clear();
     $this->articleId = $article1->id;
     $this->userId = $user1->getId();
     $this->userId2 = $user2->getId();
     $this->groupId = $group1->id;
     $this->ddc2504OtherClassId = $otherClass->id;
     $this->ddc2504ChildClassId = $childClass1->id;
     $this->username = $user1->username;
     $this->groupname = $group1->name;
     $this->topic = $article1->topic;
     $this->phonenumber = $phonenumber1->phonenumber;
 }