Commit ce6aebc8 authored by piccoloprincipe's avatar piccoloprincipe

[2.0] expanded tests for DBAL components

parent be966b0c
......@@ -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();
}
\ No newline at end of file
}
......@@ -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';
}
}
\ No newline at end of file
}
......@@ -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()
......
<?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));
}
}
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