コード例 #1
0
ファイル: PersistBench.php プロジェクト: doctrine/phpcr-odm
 public function benchPersistMany()
 {
     $parent1 = new ParentTestObj();
     $parent1->nodename = "root1";
     $parent1->name = "root1";
     $parent1->setParentDocument($this->root);
     $parent2 = new ParentTestObj();
     $parent2->name = "/root2";
     $parent2->nodename = "root2";
     $parent2->setParentDocument($this->root);
     $child = new ParentNoNodeNameTestObj();
     $child->setParentDocument($parent1);
     $child->name = "child";
     $c1 = new Comment();
     $c1->name = 'c1';
     $c1->parent = $this->root;
     $c1->setText('deutsch');
     $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group1->name = "Test!";
     $group1->id = '/functional/group1';
     $group2 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group2->name = "Test!";
     $group2->id = '/functional/group2';
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = "******";
     $user->name = "Benjamin";
     $user->addGroup($group1);
     $user->addGroup($group2);
     $this->documentManager->persist($parent1);
     $this->documentManager->persist($parent2);
     $this->documentManager->persist($child);
     $this->documentManager->persist($c1);
     $this->documentManager->persist($user);
     $this->documentManager->persist($group1);
     $this->documentManager->persist($group2);
     $this->documentManager->flush();
 }
コード例 #2
0
 /**
  * Same as findWithLanguageFallback, but all properties are nullable.
  */
 public function testFindWithLanguageFallbackNullable()
 {
     $doc = new Comment();
     $doc->id = '/functional/fallback-nullable';
     $doc->setText('Un commentaire');
     $doc->locale = 'fr';
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->dm->clear();
     $this->dm->getLocaleChooserStrategy()->setLocale('it');
     $doc = $this->dm->find(null, '/functional/fallback-nullable');
     $this->assertNotNull($doc);
     $this->assertEquals('fr', $doc->locale);
     $this->assertEquals('Un commentaire', $doc->getText());
 }
コード例 #3
0
ファイル: UnitOfWorkTest.php プロジェクト: nikophil/cmf-tests
 public function testComputeChangeSetForTranslatableDocument()
 {
     $root = $this->dm->find(null, 'functional');
     $c1 = new Comment();
     $c1->name = 'c1';
     $c1->parent = $root;
     $c1->setText('deutsch');
     $this->dm->persist($c1);
     $this->dm->bindTranslation($c1, 'de');
     $c1->setText('english');
     $this->dm->bindTranslation($c1, 'en');
     $this->dm->flush();
     $c2 = new Comment();
     $c2->name = 'c2';
     $c2->parent = $root;
     $c2->setText('deutsch');
     $this->dm->persist($c2);
     $this->dm->bindTranslation($c2, 'de');
     $c2->setText('english');
     $this->dm->bindTranslation($c2, 'en');
     $this->uow->computeChangeSets();
     $this->assertCount(1, $this->uow->getScheduledInserts());
     $this->assertCount(0, $this->uow->getScheduledUpdates());
 }