2012-03-12 12:48:14 +01:00
|
|
|
<?php
|
|
|
|
namespace Doctrine\Tests\ORM\Functional;
|
2016-05-11 02:41:26 +07:00
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
2012-03-12 12:48:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DDC-451
|
|
|
|
*/
|
2016-05-11 02:41:26 +07:00
|
|
|
class UUIDGeneratorTest extends OrmFunctionalTestCase
|
2012-03-12 12:48:14 +01:00
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
if ($this->_em->getConnection()->getDatabasePlatform()->getName() != 'mysql') {
|
|
|
|
$this->markTestSkipped('Currently restricted to MySQL platform.');
|
|
|
|
}
|
|
|
|
|
2016-12-07 23:33:41 +01:00
|
|
|
$this->_schemaTool->createSchema(
|
|
|
|
[
|
2016-12-08 18:01:04 +01:00
|
|
|
$this->_em->getClassMetadata(UUIDEntity::class)
|
2016-12-07 23:33:41 +01:00
|
|
|
]
|
|
|
|
);
|
2012-03-12 12:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGenerateUUID()
|
|
|
|
{
|
|
|
|
$entity = new UUIDEntity();
|
|
|
|
|
|
|
|
$this->_em->persist($entity);
|
|
|
|
$this->assertNotNull($entity->getId());
|
|
|
|
$this->assertTrue(strlen($entity->getId()) > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Entity
|
|
|
|
*/
|
|
|
|
class UUIDEntity
|
|
|
|
{
|
|
|
|
/** @Id @Column(type="string") @GeneratedValue(strategy="UUID") */
|
|
|
|
private $id;
|
|
|
|
/**
|
|
|
|
* Get id.
|
|
|
|
*
|
|
|
|
* @return id.
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
}
|