Rajout de doctrine/orm
[zf2.biz/application_blanche.git] / vendor / doctrine / dbal / tests / Doctrine / Tests / DBAL / Types / TimeTest.php
diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php
new file mode 100644 (file)
index 0000000..8a07b9b
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+namespace Doctrine\Tests\DBAL\Types;
+
+use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DBAL\Mocks;
+
+require_once __DIR__ . '/../../TestInit.php';
+
+class TimeTest extends \Doctrine\Tests\DbalTestCase
+{
+    protected
+        $_platform,
+        $_type;
+
+    protected function setUp()
+    {
+        $this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
+        $this->_type = Type::getType('time');
+    }
+
+    public function testTimeConvertsToDatabaseValue()
+    {
+        $this->assertTrue(
+            is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform))
+        );
+    }
+
+    public function testTimeConvertsToPHPValue()
+    {
+        $this->assertTrue(
+            $this->_type->convertToPHPValue('5:30:55', $this->_platform)
+            instanceof \DateTime
+        );
+    }
+
+    public function testInvalidTimeFormatConversion()
+    {
+        $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
+        $this->_type->convertToPHPValue('abcdefg', $this->_platform);
+    }
+
+    public function testNullConversion()
+    {
+        $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+    }
+
+    public function testConvertDateTimeToPHPValue()
+    {
+        $date = new \DateTime("now");
+        $this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform));
+    }
+}