2009-12-07 16:21:29 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
|
|
|
|
2017-05-31 16:36:31 +02:00
|
|
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
2016-05-11 01:55:12 +07:00
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
|
|
|
|
2017-05-31 07:59:04 +02:00
|
|
|
/**
|
|
|
|
* @group DDC-192
|
|
|
|
*/
|
2016-05-11 01:55:12 +07:00
|
|
|
class DDC192Test extends OrmFunctionalTestCase
|
2009-12-07 16:21:29 +00:00
|
|
|
{
|
|
|
|
public function testSchemaCreation()
|
|
|
|
{
|
2017-05-31 16:36:31 +02:00
|
|
|
$classes = [
|
|
|
|
$this->_em->getClassMetadata(DDC192User::class),
|
|
|
|
$this->_em->getClassMetadata(DDC192Phonenumber::class),
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->_schemaTool->createSchema($classes);
|
|
|
|
|
|
|
|
$tables = $this->_em->getConnection()
|
|
|
|
->getSchemaManager()
|
|
|
|
->listTableNames();
|
|
|
|
|
|
|
|
/** @var ClassMetadata $class */
|
|
|
|
foreach ($classes as $class) {
|
|
|
|
self::assertContains($class->getTableName(), $tables);
|
|
|
|
}
|
2009-12-07 16:21:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-31 07:59:04 +02:00
|
|
|
* @Entity
|
|
|
|
* @Table(name="ddc192_users")
|
2009-12-07 16:21:29 +00:00
|
|
|
*/
|
|
|
|
class DDC192User
|
2011-12-19 22:56:19 +01:00
|
|
|
{
|
2009-12-07 16:21:29 +00:00
|
|
|
/**
|
2017-05-31 07:59:04 +02:00
|
|
|
* @Id
|
|
|
|
* @Column(name="id", type="integer")
|
2009-12-07 16:21:29 +00:00
|
|
|
* @GeneratedValue(strategy="AUTO")
|
|
|
|
*/
|
|
|
|
public $id;
|
2011-12-19 22:56:19 +01:00
|
|
|
|
2009-12-07 16:21:29 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="name", type="string")
|
|
|
|
*/
|
|
|
|
public $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2017-05-31 07:59:04 +02:00
|
|
|
* @Entity
|
|
|
|
* @Table(name="ddc192_phonenumbers")
|
2009-12-07 16:21:29 +00:00
|
|
|
*/
|
|
|
|
class DDC192Phonenumber
|
|
|
|
{
|
|
|
|
/**
|
2017-05-31 07:59:04 +02:00
|
|
|
* @Id
|
|
|
|
* @Column(name="phone", type="string", length=40)
|
2009-12-07 16:21:29 +00:00
|
|
|
*/
|
|
|
|
protected $phone;
|
2011-12-19 22:56:19 +01:00
|
|
|
|
2009-12-07 16:21:29 +00:00
|
|
|
/**
|
|
|
|
* @Id
|
|
|
|
* @ManyToOne(targetEntity="DDC192User")
|
|
|
|
* @JoinColumn(name="userId", referencedColumnName="id")
|
|
|
|
*/
|
2011-05-14 00:53:22 -03:00
|
|
|
protected $User;
|
2011-12-19 22:56:19 +01:00
|
|
|
|
|
|
|
|
2017-05-31 07:59:04 +02:00
|
|
|
public function setPhone($value)
|
|
|
|
{
|
|
|
|
$this->phone = $value;
|
|
|
|
}
|
2011-12-19 22:56:19 +01:00
|
|
|
|
2017-05-31 07:59:04 +02:00
|
|
|
public function getPhone()
|
|
|
|
{
|
|
|
|
return $this->phone;
|
|
|
|
}
|
2011-12-19 22:56:19 +01:00
|
|
|
|
|
|
|
public function setUser(User $user)
|
2009-12-07 16:21:29 +00:00
|
|
|
{
|
|
|
|
$this->User = $user;
|
|
|
|
}
|
2011-12-19 22:56:19 +01:00
|
|
|
|
2017-05-31 07:59:04 +02:00
|
|
|
public function getUser()
|
|
|
|
{
|
|
|
|
return $this->User;
|
|
|
|
}
|
2014-04-07 14:43:25 +02:00
|
|
|
}
|