1
0
mirror of synced 2025-01-07 17:47:10 +03:00
doctrine2/tests/Orm/Entity/ConstructorTest.php
2008-12-18 14:08:11 +00:00

48 lines
1.1 KiB
PHP

<?php
require_once 'lib/DoctrineTestInit.php';
class Orm_Entity_ConstructorTest extends Doctrine_OrmTestCase
{
public function testFieldInitializationInConstructor()
{
$entity = new ConstructorTestEntity1("romanb");
$this->assertEquals("romanb", $entity->username);
}
}
class ConstructorTestEntity1
{
public $id;
public $username;
public function __construct($username = null)
{
if ($username !== null) {
$this->username = $username;
}
}
/* The mapping definition */
public static function initMetadata($mapping)
{
/*
$mapping->addFieldMetadata('id', array(
'doctrine.id' => true,
'doctrine.validator.constraints' => array('notnull', 'unique')
));
*/
$mapping->mapField(array(
'fieldName' => 'id',
'type' => 'integer',
'id' => true
));
$mapping->mapField(array(
'fieldName' => 'username',
'type' => 'string',
'length' => 50
));
}
}
?>