1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Adding more Tests for DateTime, Date and Time type handling, related to DBAL-22. Failures in Oracle Time Type handling have to fixed in DBAL package.

This commit is contained in:
Benjamin Eberlei 2010-06-14 23:46:04 +02:00
parent 4705c1cb03
commit 8639735e91
2 changed files with 48 additions and 3 deletions

View File

@ -14,15 +14,15 @@ class DateTimeModel
*/
public $id;
/**
* @Column(name="col_datetime", type="datetime")
* @Column(name="col_datetime", type="datetime", nullable=true)
*/
public $datetime;
/**
* @Column(name="col_date", type="date")
* @Column(name="col_date", type="date", nullable=true)
*/
public $date;
/**
* @Column(name="col_time", type="time")
* @Column(name="col_time", type="time", nullable=true)
*/
public $time;
}

View File

@ -91,4 +91,49 @@ class TypeTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertType('stdClass', $serialize->object);
}
public function testDate()
{
$dateTime = new DateTimeModel();
$dateTime->date = new \DateTime('2009-10-01', new \DateTimeZone('Europe/Berlin'));
$this->_em->persist($dateTime);
$this->_em->flush();
$this->_em->clear();
$dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id);
$this->assertType('DateTime', $dateTimeDb->date);
$this->assertEquals('2009-10-01', $dateTimeDb->date->format('Y-m-d'));
}
public function testDateTime()
{
$dateTime = new DateTimeModel();
$dateTime->datetime = new \DateTime('2009-10-02 20:10:52', new \DateTimeZone('Europe/Berlin'));
$this->_em->persist($dateTime);
$this->_em->flush();
$this->_em->clear();
$dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id);
$this->assertType('DateTime', $dateTime->datetime);
$this->assertEquals('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s'));
}
public function testTime()
{
$dateTime = new DateTimeModel();
$dateTime->time = new \DateTime('2010-01-01 19:27:20');
$this->_em->persist($dateTime);
$this->_em->flush();
$this->_em->clear();
$dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id);
$this->assertType('DateTime', $dateTime->time);
$this->assertEquals('19:27:20', $dateTime->time->format('H:i:s'));
}
}