• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CMS\CmsUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Doctrine\Tests\Models\CMS\CmsUser的典型用法代码示例。如果您正苦于以下问题:PHP CmsUser类的具体用法?PHP CmsUser怎么用?PHP CmsUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CmsUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testOrphanRemoval

 public function testOrphanRemoval()
 {
     $user = new CmsUser();
     $user->status = 'dev';
     $user->username = 'romanb';
     $user->name = 'Roman B.';
     $address = new CmsAddress();
     $address->country = 'de';
     $address->zip = 1234;
     $address->city = 'Berlin';
     $user->setAddress($address);
     $this->_em->persist($user);
     $this->_em->flush();
     $userId = $user->getId();
     $this->_em->clear();
     $userProxy = $this->_em->getReference('Doctrine\\Tests\\Models\\CMS\\CmsUser', $userId);
     $this->_em->remove($userProxy);
     $this->_em->flush();
     $this->_em->clear();
     $query = $this->_em->createQuery('SELECT u FROM Doctrine\\Tests\\Models\\CMS\\CmsUser u');
     $result = $query->getResult();
     $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager');
     $query = $this->_em->createQuery('SELECT a FROM Doctrine\\Tests\\Models\\CMS\\CmsAddress a');
     $result = $query->getResult();
     $this->assertEquals(0, count($result), 'CmsAddress should be removed by orphanRemoval');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:26,代码来源:OneToOneOrphanRemovalTest.php


示例2: testManyToManyAddRemove

 public function testManyToManyAddRemove()
 {
     // Set up user with 2 groups
     $user = new CmsUser();
     $user->username = 'romanb';
     $user->status = 'dev';
     $user->name = 'Roman B.';
     $group1 = new CmsGroup();
     $group1->name = 'Developers';
     $group2 = new CmsGroup();
     $group2->name = 'Humans';
     $user->addGroup($group1);
     $user->addGroup($group2);
     $this->_em->persist($user);
     // cascades to groups
     $this->_em->flush();
     $this->_em->clear();
     $uRep = $this->_em->getRepository(get_class($user));
     // Get user
     $user = $uRep->findOneById($user->getId());
     $this->assertFalse($user->getGroups()->isInitialized());
     // Check groups
     $this->assertEquals(2, $user->getGroups()->count());
     $this->assertTrue($user->getGroups()->isInitialized());
     // Remove first group
     unset($user->groups[0]);
     //$user->getGroups()->remove(0);
     $this->_em->flush();
     $this->_em->clear();
     // Reload same user
     $user2 = $uRep->findOneById($user->getId());
     // Check groups
     $this->assertEquals(1, $user2->getGroups()->count());
 }
开发者ID:andreia,项目名称:doctrine,代码行数:34,代码来源:ManyToManyBasicAssociationTest.php


示例3: setUser

 public function setUser(CmsUser $user)
 {
     if ($this->user !== $user) {
         $this->user = $user;
         $user->setAddress($this);
     }
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:7,代码来源:CmsAddress.php


示例4: testIssue

 public function testIssue()
 {
     $phone = new CmsPhonenumber();
     $phone->phonenumber = "1234";
     // puts user and phone into commit order calculator
     $this->_em->persist($phone);
     $this->_em->flush();
     $address = new \Doctrine\Tests\Models\CMS\CmsAddress();
     $address->city = "bonn";
     $address->country = "Germany";
     $address->street = "somestreet!";
     $address->zip = 12345;
     $this->_em->persist($address);
     $user = new CmsUser();
     $user->username = "beberlei";
     $user->name = "benjamin";
     $user->status = "active";
     $user->setAddress($address);
     // puts user and address into commit order calculator, but does not calculate user dependencies new
     $this->_em->persist($user);
     $this->_em->flush();
     $this->_em->remove($user->getAddress());
     $this->_em->remove($user);
     $this->_em->flush();
 }
开发者ID:selimcr,项目名称:servigases,代码行数:25,代码来源:DDC1306Test.php


示例5: testSerializeUnserializeModifyMerge

 public function testSerializeUnserializeModifyMerge()
 {
     //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
     $user = new CmsUser();
     $user->name = 'Guilherme';
     $user->username = 'gblanco';
     $user->status = 'developer';
     $ph1 = new CmsPhonenumber();
     $ph1->phonenumber = 1234;
     $user->addPhonenumber($ph1);
     $this->_em->persist($user);
     $this->_em->flush();
     $this->assertTrue($this->_em->contains($user));
     $this->assertTrue($user->phonenumbers->isInitialized());
     $serialized = serialize($user);
     $this->_em->clear();
     $this->assertFalse($this->_em->contains($user));
     unset($user);
     $user = unserialize($serialized);
     $ph2 = new CmsPhonenumber();
     $ph2->phonenumber = 56789;
     $user->addPhonenumber($ph2);
     $this->assertEquals(2, count($user->getPhonenumbers()));
     $this->assertFalse($this->_em->contains($user));
     $this->_em->persist($ph2);
     // Merge back in
     $user = $this->_em->merge($user);
     // merge cascaded to phonenumbers
     $this->_em->flush();
     $this->assertTrue($this->_em->contains($user));
     $this->assertEquals(2, count($user->getPhonenumbers()));
     $phonenumbers = $user->getPhonenumbers();
     $this->assertTrue($this->_em->contains($phonenumbers[0]));
     $this->assertTrue($this->_em->contains($phonenumbers[1]));
 }
开发者ID:jeffreiffers,项目名称:doctrine2,代码行数:35,代码来源:DetachedEntityTest.php


示例6: setUp

 public function setUp()
 {
     $this->useModelSet('cms');
     parent::setUp();
     $user1 = new CmsUser();
     $user1->username = "beberlei";
     $user1->name = "Benjamin";
     $user1->status = "active";
     $group1 = new CmsGroup();
     $group1->name = "test";
     $group2 = new CmsGroup();
     $group2->name = "test";
     $user1->addGroup($group1);
     $user1->addGroup($group2);
     $user2 = new CmsUser();
     $user2->username = "romanb";
     $user2->name = "Roman";
     $user2->status = "active";
     $this->_em->persist($user1);
     $this->_em->persist($user2);
     $this->_em->persist($group1);
     $this->_em->persist($group2);
     $this->_em->flush();
     $this->_em->clear();
     $this->user1 = $this->_em->find(get_class($user1), $user1->id);
     $this->user2 = $this->_em->find(get_class($user1), $user2->id);
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:27,代码来源:DDC1643Test.php


示例7: testJoinQueries

 public function testJoinQueries()
 {
     $user = new CmsUser();
     $user->name = 'Guilherme';
     $user->username = 'gblanco';
     $user->status = 'developer';
     $article1 = new CmsArticle();
     $article1->topic = "Doctrine 2";
     $article1->text = "This is an introduction to Doctrine 2.";
     $user->addArticle($article1);
     $article2 = new CmsArticle();
     $article2->topic = "Symfony 2";
     $article2->text = "This is an introduction to Symfony 2.";
     $user->addArticle($article2);
     $this->_em->persist($user);
     $this->_em->persist($article1);
     $this->_em->persist($article2);
     $this->_em->flush();
     $this->_em->clear();
     $query = $this->_em->createQuery("select u, a from Doctrine\\Tests\\Models\\CMS\\CmsUser u join u.articles a");
     $users = $query->getResult();
     $this->assertEquals(1, count($users));
     $this->assertTrue($users[0] instanceof CmsUser);
     $this->assertEquals(2, count($users[0]->articles));
     $this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic);
     $this->assertEquals('Symfony 2', $users[0]->articles[1]->topic);
 }
开发者ID:andreia,项目名称:doctrine,代码行数:27,代码来源:QueryTest.php


示例8: createNewValidUser

 /**
  * @return CmsUser
  */
 private function createNewValidUser()
 {
     $user = new CmsUser();
     $user->username = 'fran6co';
     $user->name = 'Francisco Facioni';
     $group = new CmsGroup();
     $group->name = "users";
     $user->addGroup($group);
     return $user;
 }
开发者ID:selimcr,项目名称:servigases,代码行数:13,代码来源:ManyToManyEventTest.php


示例9: testSerializeUnserializeModifyMerge

    public function testSerializeUnserializeModifyMerge()
    {
        //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
        $user = new CmsUser;
        $user->name = 'Guilherme';
        $user->username = 'gblanco';
        $user->status = 'developer';
        
        $ph1 = new CmsPhonenumber;
        $ph1->phonenumber = "1234";
        $user->addPhonenumber($ph1);

        $this->_em->persist($user);
        $this->_em->flush();
        $this->assertTrue($this->_em->contains($user));
        $this->assertTrue($user->phonenumbers->isInitialized());
        
        $serialized = serialize($user);
        $this->_em->clear();
        $this->assertFalse($this->_em->contains($user));        
        unset($user);
        
        $user = unserialize($serialized);

        $this->assertEquals(1, count($user->getPhonenumbers()), "Pre-Condition: 1 Phonenumber");
        
        $ph2 = new CmsPhonenumber;
        $ph2->phonenumber = "56789";
        $user->addPhonenumber($ph2);
        $oldPhonenumbers = $user->getPhonenumbers();
        $this->assertEquals(2, count($oldPhonenumbers), "Pre-Condition: 2 Phonenumbers");
        $this->assertFalse($this->_em->contains($user));
        
        $this->_em->persist($ph2);

        // Merge back in
        $user = $this->_em->merge($user); // merge cascaded to phonenumbers
        $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[0]->user);
        $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[1]->user);
        $im = $this->_em->getUnitOfWork()->getIdentityMap();
        $this->_em->flush();
        
        $this->assertTrue($this->_em->contains($user), "Failed to assert that merged user is contained inside EntityManager persistence context.");
        $phonenumbers = $user->getPhonenumbers();
        $this->assertNotSame($oldPhonenumbers, $phonenumbers, "Merge should replace the Detached Collection with a new PersistentCollection.");
        $this->assertEquals(2, count($phonenumbers), "Failed to assert that two phonenumbers are contained in the merged users phonenumber collection.");

        $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[1]);
        $this->assertTrue($this->_em->contains($phonenumbers[1]), "Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context.");

        $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[0]);
        $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0]));
        $this->assertTrue($this->_em->contains($phonenumbers[0]), "Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context.");
    }
开发者ID:naderman,项目名称:doctrine2,代码行数:54,代码来源:DetachedEntityTest.php


示例10: buildUser

 public function buildUser($name, $username, $status, $address)
 {
     $user = new CmsUser();
     $user->name = $name;
     $user->username = $username;
     $user->status = $status;
     $user->setAddress($address);
     $this->_em->persist($user);
     $this->_em->flush();
     return $user;
 }
开发者ID:relo-san,项目名称:doctrine2,代码行数:11,代码来源:EntityRepositoryTest.php


示例11: testFindWithProxyName

 /**
  * Verifying that proxies can be used without problems as query parameters
  */
 public function testFindWithProxyName()
 {
     $result = $this->_em->find('Doctrine\\Tests\\Proxies\\__CG__\\Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId());
     $this->assertSame($this->user->getId(), $result->getId());
     $this->_em->clear();
     $result = $this->_em->getReference('Doctrine\\Tests\\Proxies\\__CG__\\Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId());
     $this->assertSame($this->user->getId(), $result->getId());
     $this->_em->clear();
     $result = $this->_em->getRepository('Doctrine\\Tests\\Proxies\\__CG__\\Doctrine\\Tests\\Models\\CMS\\CmsUser')->findOneBy(array('username' => $this->user->username));
     $this->assertSame($this->user->getId(), $result->getId());
     $this->_em->clear();
     $result = $this->_em->createQuery('SELECT u FROM Doctrine\\Tests\\Proxies\\__CG__\\Doctrine\\Tests\\Models\\CMS\\CmsUser u WHERE u.id = ?1')->setParameter(1, $this->user->getId())->getSingleResult();
     $this->assertSame($this->user->getId(), $result->getId());
     $this->_em->clear();
 }
开发者ID:selimcr,项目名称:servigases,代码行数:18,代码来源:ProxiesLikeEntitiesTest.php


示例12: setUp

 protected function setUp()
 {
     $this->useModelSet('cms');
     parent::setUp();
     $user = new CmsUser();
     $user->status = 'dev';
     $user->username = 'romanb';
     $user->name = 'Roman B.';
     $phone = new CmsPhonenumber();
     $phone->phonenumber = '123456';
     $user->addPhonenumber($phone);
     $this->_em->persist($user);
     $this->_em->flush();
     $this->userId = $user->getId();
     $this->_em->clear();
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:16,代码来源:OneToManyOrphanRemovalTest.php


示例13: testGivenOrphanRemovalOneToOne_WhenReplacing_ThenNoUniqueConstraintError

 public function testGivenOrphanRemovalOneToOne_WhenReplacing_ThenNoUniqueConstraintError()
 {
     $user = new CmsUser();
     $user->name = "Benjamin";
     $user->username = "beberlei";
     $user->status = "something";
     $user->setEmail($email = new CmsEmail());
     $email->setEmail("[email protected]");
     $this->_em->persist($user);
     $this->_em->flush();
     $this->assertTrue($this->_em->contains($email));
     $user->setEmail($newEmail = new CmsEmail());
     $newEmail->setEmail("[email protected]");
     $this->_em->flush();
     $this->assertFalse($this->_em->contains($email));
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:16,代码来源:DDC1666Test.php


示例14: createAndPersistUser

 protected function createAndPersistUser()
 {
     $user = new CmsUser();
     $user->name = 'Luka';
     $user->username = 'lukacho';
     $user->status = 'developer';
     foreach (array(1111, 2222, 3333, 4444) as $number) {
         $phone = new CmsPhonenumber();
         $phone->phonenumber = $number;
         $user->addPhonenumber($phone);
     }
     foreach (array('Moshers', 'Headbangers') as $groupName) {
         $group = new CmsGroup();
         $group->setName($groupName);
         $user->addGroup($group);
     }
     $this->_em->persist($user);
     return $user;
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:19,代码来源:DDC501Test.php


示例15: testIssue

 public function testIssue()
 {
     $em = $this->_em;
     $uow = $em->getUnitOfWork();
     $originalArticle = new CmsArticle();
     $originalUser = new CmsUser();
     $originalArticle->topic = 'Unit Test';
     $originalArticle->text = 'How to write a test';
     $originalUser->name = 'Doctrine Bot';
     $originalUser->username = 'DoctrineBot';
     $originalUser->status = 'active';
     $originalUser->addArticle($originalArticle);
     $em->persist($originalUser);
     $em->persist($originalArticle);
     $em->flush();
     $em->clear();
     $article = $em->find('Doctrine\\Tests\\Models\\CMS\\CmsArticle', $originalArticle->id);
     $user = new CmsUser();
     $user->name = 'Doctrine Bot 2.0';
     $user->username = 'BotDoctrine2';
     $user->status = 'new';
     $article->setAuthor($user);
     $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalArticle));
     $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalUser));
     $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article));
     $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user));
     $em->detach($user);
     $em->detach($article);
     $userMerged = $em->merge($user);
     $articleMerged = $em->merge($article);
     $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user));
     $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($article));
     $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($userMerged));
     $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($articleMerged));
     $this->assertNotSame($user, $userMerged);
     $this->assertNotSame($article, $articleMerged);
     $this->assertNotSame($userMerged, $articleMerged->user);
     $this->assertSame($user, $articleMerged->user);
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:39,代码来源:DDC2409Test.php


示例16: testOrphanRemovalWhenUnlink

 public function testOrphanRemovalWhenUnlink()
 {
     $user = new CmsUser();
     $user->status = 'dev';
     $user->username = 'beberlei';
     $user->name = 'Bejamin Eberlei';
     $email = new CmsEmail();
     $email->email = '[email protected]';
     $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');
 }
开发者ID:ncking,项目名称:doctrine2,代码行数:22,代码来源:OneToOneOrphanRemovalTest.php


示例17: testCollectionChangesInsideTransaction

 /**
  * @group DDC-767
  */
 public function testCollectionChangesInsideTransaction()
 {
     $user = new CmsUser();
     $user->name = "beberlei";
     $user->status = "active";
     $user->username = "beberlei";
     $group1 = new CmsGroup();
     $group1->name = "foo";
     $group2 = new CmsGroup();
     $group2->name = "bar";
     $group3 = new CmsGroup();
     $group3->name = "baz";
     $user->addGroup($group1);
     $user->addGroup($group2);
     $this->_em->persist($user);
     $this->_em->persist($group1);
     $this->_em->persist($group2);
     $this->_em->persist($group3);
     $this->_em->flush();
     $this->_em->clear();
     /* @var $pUser CmsUser */
     $pUser = $this->_em->find(get_class($user), $user->id);
     $this->assertNotNull($pUser, "User not retrieved from database.");
     $groups = array($group2->id, $group3->id);
     try {
         $this->_em->beginTransaction();
         $pUser->groups->clear();
         $this->_em->flush();
         // Add new
         foreach ($groups as $groupId) {
             $pUser->addGroup($this->_em->find(get_class($group1), $groupId));
         }
         $this->_em->flush();
         $this->_em->commit();
     } catch (\Exception $e) {
         $this->_em->rollback();
     }
 }
开发者ID:selimcr,项目名称:servigases,代码行数:41,代码来源:DDC767Test.php


示例18: testJoinedOneToOneNativeQuery

 public function testJoinedOneToOneNativeQuery()
 {
     $user = new CmsUser();
     $user->name = 'Roman';
     $user->username = 'romanb';
     $user->status = 'dev';
     $addr = new CmsAddress();
     $addr->country = 'germany';
     $addr->zip = 10827;
     $addr->city = 'Berlin';
     $user->setAddress($addr);
     $this->_em->persist($user);
     $this->_em->flush();
     $this->_em->clear();
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'u');
     $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
     $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name');
     $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status');
     $rsm->addJoinedEntityResult('Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'a', 'u', 'address');
     $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('a_id'), 'id');
     $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country');
     $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip');
     $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city');
     $query = $this->_em->createNativeQuery('SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm);
     $query->setParameter(1, 'romanb');
     $users = $query->getResult();
     $this->assertEquals(1, count($users));
     $this->assertTrue($users[0] instanceof CmsUser);
     $this->assertEquals('Roman', $users[0]->name);
     $this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
     $this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
     $this->assertTrue($users[0]->getAddress() instanceof CmsAddress);
     $this->assertTrue($users[0]->getAddress()->getUser() == $users[0]);
     $this->assertEquals('germany', $users[0]->getAddress()->getCountry());
     $this->assertEquals(10827, $users[0]->getAddress()->getZipCode());
     $this->assertEquals('Berlin', $users[0]->getAddress()->getCity());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:38,代码来源:NativeQueryTest.php


示例19: benchPersistMany

 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 = "beberlei";
     $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();
 }
开发者ID:doctrine,项目名称:phpcr-odm,代码行数:37,代码来源:PersistBench.php


示例20: testOrphanRemoval

 public function testOrphanRemoval()
 {
     $user = new CmsUser();
     $user->status = 'dev';
     $user->username = 'romanb';
     $user->name = 'Roman B.';
     $phone = new CmsPhonenumber();
     $phone->phonenumber = '123456';
     $user->addPhonenumber($phone);
     $this->_em->persist($user);
     $this->_em->flush();
     $userId = $user->getId();
     $this->_em->clear();
     $userProxy = $this->_em->getReference('Doctrine\\Tests\\Models\\CMS\\CmsUser', $userId);
     $this->_em->remove($userProxy);
     $this->_em->flush();
     $this->_em->clear();
     $query = $this->_em->createQuery('SELECT u FROM Doctrine\\Tests\\Models\\CMS\\CmsUser u');
     $result = $query->getResult();
     $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager');
     $query = $this->_em->createQuery('SELECT p FROM Doctrine\\Tests\\Models\\CMS\\CmsPhonenumber p');
     $result = $query->getResult();
     $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval');
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:24,代码来源:OneToManyOrphanRemovalTest.php



注:本文中的Doctrine\Tests\Models\CMS\CmsUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Documents\User类代码示例发布时间:2022-05-23
下一篇:
PHP Tests\OrmTestCase类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap