2009-07-16 00:18:40 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Mapping;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
|
|
use Doctrine\ORM\Events;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../../TestInit.php';
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2009-07-16 00:18:40 +04:00
|
|
|
class ClassMetadataLoadEventTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
{
|
|
|
|
public function testEvent()
|
|
|
|
{
|
|
|
|
$em = $this->_getTestEntityManager();
|
|
|
|
$metadataFactory = $em->getMetadataFactory();
|
|
|
|
$evm = $em->getEventManager();
|
|
|
|
$evm->addEventListener(Events::loadClassMetadata, $this);
|
|
|
|
$classMetadata = $metadataFactory->getMetadataFor('Doctrine\Tests\ORM\Mapping\LoadEventTestEntity');
|
|
|
|
$this->assertTrue($classMetadata->hasField('about'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loadClassMetadata(\Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs)
|
|
|
|
{
|
|
|
|
$classMetadata = $eventArgs->getClassMetadata();
|
|
|
|
$field = array(
|
|
|
|
'fieldName' => 'about',
|
|
|
|
'type' => 'string',
|
|
|
|
'length' => 255
|
|
|
|
);
|
|
|
|
$classMetadata->mapField($field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Entity
|
|
|
|
* @Table(name="load_event_test_entity")
|
|
|
|
*/
|
|
|
|
class LoadEventTestEntity
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @Id @Column(type="integer")
|
|
|
|
* @GeneratedValue(strategy="AUTO")
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
/**
|
|
|
|
* @Column(type="string", length=255)
|
|
|
|
*/
|
|
|
|
private $name;
|
|
|
|
|
|
|
|
private $about;
|
|
|
|
}
|