当前位置: 首页>>代码示例>>PHP>>正文


PHP CMS\CmsUser类代码示例

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


在下文中一共展示了CmsUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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("kontakt@beberlei.de");
     $this->_em->persist($user);
     $this->_em->flush();
     $this->assertTrue($this->_em->contains($email));
     $user->setEmail($newEmail = new CmsEmail());
     $newEmail->setEmail("benjamin.eberlei@googlemail.com");
     $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


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