[2.0] expanded tests for DBAL components
This commit is contained in:
parent
be966b0cd9
commit
ce6aebc8ab
@ -39,6 +39,7 @@ class AllTests
|
||||
$suite->addTestSuite('Doctrine\Tests\DBAL\Types\DecimalTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\DBAL\Types\IntegerTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\DBAL\Types\SmallIntTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\DBAL\Types\StringTest');
|
||||
|
||||
$suite->addTest(Functional\AllTests::suite());
|
||||
|
||||
@ -48,4 +49,4 @@ class AllTests
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'Dbal_Platforms_AllTests::main') {
|
||||
AllTests::main();
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,19 @@ class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
public function getBigIntTypeDeclarationSql(array $columnDef) {}
|
||||
public function getSmallIntTypeDeclarationSql(array $columnDef) {}
|
||||
public function _getCommonIntegerTypeDeclarationSql(array $columnDef) {}
|
||||
public function getVarcharTypeDeclarationSql(array $field) {}
|
||||
|
||||
public function getVarcharTypeDeclarationSql(array $field)
|
||||
{
|
||||
return "DUMMYVARCHAR()";
|
||||
}
|
||||
|
||||
public function getVarcharDefaultLength()
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'mock';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,12 +80,29 @@ class PostgreSqlPlatformTest extends \Doctrine\Tests\DbalTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testGeneratesForeignKeySqlForNonStandardOptions()
|
||||
{
|
||||
$definition = array(
|
||||
'name' => 'my_fk',
|
||||
'local' => 'foreign_id',
|
||||
'foreign' => 'id',
|
||||
'foreignTable' => 'my_table',
|
||||
'onDelete' => 'CASCADE'
|
||||
);
|
||||
$this->assertEquals(
|
||||
" CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE",
|
||||
$this->_platform->getForeignKeyDeclarationSql($definition)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGeneratesSqlSnippets()
|
||||
{
|
||||
$this->assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
|
||||
$this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
|
||||
$this->assertEquals('RANDOM()', $this->_platform->getRandomExpression(), 'Random function is not correct');
|
||||
$this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
|
||||
$this->assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
|
||||
$this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct');
|
||||
}
|
||||
|
||||
public function testGeneratesTransactionCommands()
|
||||
|
31
tests/Doctrine/Tests/DBAL/Types/StringTest.php
Normal file
31
tests/Doctrine/Tests/DBAL/Types/StringTest.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\DBAL\Types;
|
||||
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\Tests\DBAL\Mocks;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
class StringTest extends \Doctrine\Tests\DbalTestCase
|
||||
{
|
||||
protected
|
||||
$_platform,
|
||||
$_type;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
|
||||
$this->_type = Type::getType('string');
|
||||
}
|
||||
|
||||
public function testReturnsSqlDeclarationFromPlatformVarchar()
|
||||
{
|
||||
$this->assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform));
|
||||
}
|
||||
|
||||
public function testReturnsDefaultLengthFromPlatformVarchar()
|
||||
{
|
||||
$this->assertEquals(255, $this->_type->getDefaultLength($this->_platform));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user