Commit 6e3afd5f authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #2851 from greg0ire/default_date_test

Test default value declaration for the date type
parents 24b4ebf0 f1f728f1
...@@ -563,6 +563,20 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -563,6 +563,20 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
} }
} }
public function testGetDefaultValueDeclarationSQLForDateType()
{
$currentDateSql = $this->_platform->getCurrentDateSQL();
$field = array(
'type' => Type::getType('date'),
'default' => $currentDateSql,
);
$this->assertEquals(
' DEFAULT '.$currentDateSql,
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
/** /**
* @group DBAL-45 * @group DBAL-45
*/ */
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Platforms; namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Platforms\SQLServer2008Platform; use Doctrine\DBAL\Platforms\SQLServer2008Platform;
use Doctrine\DBAL\Types\Type;
class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase
{ {
...@@ -19,4 +20,18 @@ class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase ...@@ -19,4 +20,18 @@ class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase
array()) array())
); );
} }
public function testGetDefaultValueDeclarationSQLForDateType()
{
$currentDateSql = $this->_platform->getCurrentDateSQL();
$field = array(
'type' => Type::getType('date'),
'default' => $currentDateSql,
);
$this->assertEquals(
" DEFAULT '".$currentDateSql."'",
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
} }
...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms; ...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Types\Type;
class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase
{ {
...@@ -371,4 +372,18 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase ...@@ -371,4 +372,18 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase
$sql = $this->_platform->modifyLimitQuery($querySql, 10); $sql = $this->_platform->modifyLimitQuery($querySql, 10);
self::assertEquals($expectedSql, $sql); self::assertEquals($expectedSql, $sql);
} }
public function testGetDefaultValueDeclarationSQLForDateType()
{
$currentDateSql = $this->_platform->getCurrentDateSQL();
$field = array(
'type' => Type::getType('date'),
'default' => $currentDateSql,
);
$this->assertEquals(
" DEFAULT '".$currentDateSql."'",
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
} }
...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms; ...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\LockMode; use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Types\Type;
class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
{ {
...@@ -58,4 +59,17 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase ...@@ -58,4 +59,17 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
); );
} }
public function testGetDefaultValueDeclarationSQLForDateType()
{
$currentDateSql = $this->_platform->getCurrentDateSQL();
$field = array(
'type' => Type::getType('date'),
'default' => $currentDateSql,
);
$this->assertEquals(
" DEFAULT '".$currentDateSql."'",
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment