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


PHP CmsUser::setAddress方法代码示例

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


在下文中一共展示了CmsUser::setAddress方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:ncking,项目名称:doctrine2,代码行数:26,代码来源:OneToOneOrphanRemovalTest.php

示例2: testBasicIdentityManagement

 public function testBasicIdentityManagement()
 {
     $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();
     $this->_em->clear();
     $user2 = $this->_em->find(get_class($user), $user->getId());
     $this->assertTrue($user2 !== $user);
     $user3 = $this->_em->find(get_class($user), $user->getId());
     $this->assertTrue($user2 === $user3);
     $address2 = $this->_em->find(get_class($address), $address->getId());
     $this->assertTrue($address2 !== $address);
     $address3 = $this->_em->find(get_class($address), $address->getId());
     $this->assertTrue($address2 === $address3);
     $this->assertTrue($user2->getAddress() === $address2);
     // !!!
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:25,代码来源:IdentityMapTest.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: 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

示例6: loadFixtures

 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 = '1test';
     $u1->status = 'developer';
     $u1->email->email = 'email@test1.com';
     $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 = '2test';
     $u2->status = 'developer';
     $u2->email->email = 'email@test2.com';
     $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 = '3test';
     $u3->status = 'developer';
     $u3->email->email = 'email@test3.com';
     $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);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:51,代码来源:NewOperatorTest.php

示例7: 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

示例8: loadAssociatedFixture

 public function loadAssociatedFixture()
 {
     $address = new CmsAddress();
     $address->city = "Berlin";
     $address->country = "Germany";
     $address->street = "Foostreet";
     $address->zip = "12345";
     $user = new CmsUser();
     $user->name = 'Roman';
     $user->username = 'romanb';
     $user->status = 'freak';
     $user->setAddress($address);
     $this->_em->persist($user);
     $this->_em->persist($address);
     $this->_em->flush();
     $this->_em->clear();
     return array($user->id, $address->id);
 }
开发者ID:nekogami,项目名称:doctrine2,代码行数:18,代码来源:EntityRepositoryTest.php

示例9: testMultipleEntityResults

 /**
  * @group DDC-1663
  * DQL : SELECT u, a, COUNT(p) AS numphones FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.address a JOIN u.phonenumbers p
  */
 public function testMultipleEntityResults()
 {
     $user = new CmsUser();
     $user->name = 'Fabio B. Silva';
     $user->username = 'FabioBatSilva';
     $user->status = 'dev';
     $addr = new CmsAddress();
     $addr->country = 'Brazil';
     $addr->zip = 10827;
     $addr->city = 'São Paulo';
     $phone = new CmsPhonenumber();
     $phone->phonenumber = 424242;
     $user->setAddress($addr);
     $user->addPhonenumber($phone);
     $this->_em->clear();
     $this->_em->persist($user);
     $this->_em->flush();
     $this->_em->clear();
     $repository = $this->_em->getRepository('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $query = $repository->createNativeNamedQuery('fetchMultipleJoinsEntityResults');
     $result = $query->getResult();
     $this->assertEquals(1, count($result));
     $this->assertTrue(is_array($result[0]));
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\CMS\\CmsUser', $result[0][0]);
     $this->assertEquals('Fabio B. Silva', $result[0][0]->name);
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\CMS\\CmsAddress', $result[0][0]->getAddress());
     $this->assertTrue($result[0][0]->getAddress()->getUser() == $result[0][0]);
     $this->assertEquals('Brazil', $result[0][0]->getAddress()->getCountry());
     $this->assertEquals(10827, $result[0][0]->getAddress()->getZipCode());
     $this->assertEquals(1, $result[0]['numphones']);
 }
开发者ID:relo-san,项目名称:doctrine2,代码行数:35,代码来源:NativeQueryTest.php

示例10: testQueryEntityByReference

 public function testQueryEntityByReference()
 {
     $user = new CmsUser();
     $user->name = 'Guilherme';
     $user->username = 'gblanco';
     $user->status = 'developer';
     $address = new CmsAddress();
     $address->country = 'Germany';
     $address->city = 'Berlin';
     $address->zip = '12345';
     $user->setAddress($address);
     $this->_em->transactional(function ($em) use($user) {
         $em->persist($user);
     });
     $this->_em->clear();
     //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
     $userRef = $this->_em->getReference('Doctrine\\Tests\\Models\\CMS\\CmsUser', $user->getId());
     $address2 = $this->_em->createQuery('select a from Doctrine\\Tests\\Models\\CMS\\CmsAddress a where a.user = :user')->setParameter('user', $userRef)->getSingleResult();
     $this->assertTrue($address2->getUser() instanceof \Doctrine\ORM\Proxy\Proxy);
     $this->assertTrue($userRef === $address2->getUser());
     $this->assertFalse($userRef->__isInitialized__);
     $this->assertEquals('Germany', $address2->country);
     $this->assertEquals('Berlin', $address2->city);
     $this->assertEquals('12345', $address2->zip);
 }
开发者ID:viniciusferreira,项目名称:doctrine2,代码行数:25,代码来源:BasicFunctionalTest.php

示例11: testJoinedOneToOneNativeQueryWithRSMBuilder

    public function testJoinedOneToOneNativeQueryWithRSMBuilder()
    {
        $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 ResultSetMappingBuilder($this->_em);
        $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u');
        $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address', array('id' => 'a_id'));

        $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id 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->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
        $this->assertEquals('Roman', $users[0]->name);
        $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
        $this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
        $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress());
        $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());

        $this->_em->clear();

        $rsm = new ResultSetMappingBuilder($this->_em);
        $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a');
        $query = $this->_em->createNativeQuery('SELECT a.* FROM cms_addresses a WHERE a.id = ?', $rsm);
        $query->setParameter(1, $addr->getId());
        $address = $query->getSingleResult();

        $this->assertNotNull($address->getUser());
        $this->assertEquals($user->name, $address->getUser()->getName());
    }
开发者ID:naderman,项目名称:doctrine2,代码行数:52,代码来源:NativeQueryTest.php

示例12: loadFixture

 private function loadFixture()
 {
     $user = new CmsUser();
     $user->name = 'Roman';
     $user->username = 'romanb';
     $user->status = 'developer';
     $address = new CmsAddress();
     $address->country = 'Germany';
     $address->city = 'Berlin';
     $address->zip = '12345';
     $user->setAddress($address);
     $email = new CmsEmail();
     $email->setEmail('roman@domain.com');
     $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();
 }
开发者ID:selimcr,项目名称:servigases,代码行数:25,代码来源:PostLoadEventTest.php


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