3 namespace Doctrine\Tests\DBAL\Types;
5 use Doctrine\DBAL\Types\Type;
6 use Doctrine\Tests\DBAL\Mocks;
8 require_once __DIR__ . '/../../TestInit.php';
10 class TimeTest extends \Doctrine\Tests\DbalTestCase
16 protected function setUp()
18 $this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
19 $this->_type = Type::getType('time');
22 public function testTimeConvertsToDatabaseValue()
25 is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform))
29 public function testTimeConvertsToPHPValue()
32 $this->_type->convertToPHPValue('5:30:55', $this->_platform)
37 public function testInvalidTimeFormatConversion()
39 $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
40 $this->_type->convertToPHPValue('abcdefg', $this->_platform);
43 public function testNullConversion()
45 $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
48 public function testConvertDateTimeToPHPValue()
50 $date = new \DateTime("now");
51 $this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform));