Bravo3\Orm\Tests\Entities\OneToOne\User::setId PHP Method

setId() public method

Set Id
public setId ( integer $id )
$id integer
    public function setId($id)
    {
        $this->id = $id;
        return $this;
    }

Usage Example

コード例 #1
0
ファイル: IndexTest.php プロジェクト: bravo3/orm
 /**
  * @dataProvider entityManagerDataProvider
  * @param EntityManager $em
  */
 public function testRelatedIndexDeletion(EntityManager $em)
 {
     $home = new Address();
     $home->setId(44)->setStreet('Oxford St');
     $work = new Address();
     $work->setId(45)->setStreet('George St');
     $user = new User();
     $user->setId(23)->setName('Barry')->setAddress($home);
     $em->persist($user)->persist($home)->persist($work)->flush();
     /** @var User|OrmProxyInterface $user_home */
     $user_home = $em->retrieveByIndex(User::class, 'slug', $user->getId() . '.' . $home->getId());
     $this->assertEquals(23, $user_home->getId());
     $this->assertEquals('Oxford St', $user_home->getAddress()->getStreet());
     $slug = $user_home->getIndexOriginalValue('slug');
     $this->assertEquals('23.44', $slug);
     $user_home->setName('Other Barry');
     $user_home->setAddress($work);
     $em->persist($user_home)->flush();
     /** @var User $user_work */
     $user_work = $em->retrieveByIndex(User::class, 'slug', $user->getId() . '.' . $work->getId());
     $this->assertEquals(23, $user_work->getId());
     $this->assertEquals('George St', $user_work->getAddress()->getStreet());
     $this->setExpectedException(NotFoundException::class);
     $em->retrieveByIndex(User::class, 'slug', $user->getId() . '.' . $home->getId());
 }
All Usage Examples Of Bravo3\Orm\Tests\Entities\OneToOne\User::setId