ConstructorTest.php 570 Bytes
Newer Older
1 2 3 4
<?php

namespace Doctrine\Tests\ORM\Entity;

5
require_once __DIR__ . '/../../TestInit.php';
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 
class ConstructorTest extends \Doctrine\Tests\OrmTestCase
{
    public function testFieldInitializationInConstructor()
    {
        $entity = new ConstructorTestEntity1("romanb");
        $this->assertEquals("romanb", $entity->username);        
    }
}

class ConstructorTestEntity1
{
    private $id;
    public $username;

    public function __construct($username = null)
    {
        if ($username !== null) {
            $this->username = $username;
        }
    }
}