From 398c819161d4d6ba7a79dbf579a09f139a976a70 Mon Sep 17 00:00:00 2001 From: zYne Date: Fri, 29 Dec 2006 22:12:36 +0000 Subject: [PATCH] tests for the mssql datadict driver --- tests/DataDict/MssqlTestCase.php | 105 +++++++++++++++++++++++++++++- tests/DataDict/OracleTestCase.php | 6 +- tests/DataDict/PgsqlTestCase.php | 6 +- tests/DataDict/SqliteTestCase.php | 6 +- 4 files changed, 107 insertions(+), 16 deletions(-) diff --git a/tests/DataDict/MssqlTestCase.php b/tests/DataDict/MssqlTestCase.php index 0705b1f34..93d0ea757 100644 --- a/tests/DataDict/MssqlTestCase.php +++ b/tests/DataDict/MssqlTestCase.php @@ -1,7 +1,106 @@ . + */ + +/** + * Doctrine_DataDict_Mysql_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_DataDict_Mssql_TestCase extends Doctrine_UnitTestCase { + public function testGetPortableDeclarationForUnknownNativeTypeThrowsException() { + try { + $this->dataDict->getPortableDeclaration(array('type' => 'some_unknown_type')); + $this->fail(); + } catch(Doctrine_DataDict_Mssql_Exception $e) { + $this->pass(); + } + } + public function testGetPortableDeclarationSupportsNativeBitType() { + $type = $this->dataDict->getPortableDeclaration(array('type' => 'bit')); + + $this->assertEqual($type, array(array('boolean'), null, null, null)); + } + public function testGetPortableDeclarationSupportsNativeStringTypes() { + $type = $this->dataDict->getPortableDeclaration(array('type' => 'text')); + + $this->assertEqual($type, array(array('string', 'clob'), null, null, null)); + + $type = $this->dataDict->getPortableDeclaration(array('type' => 'char', 'length' => 1)); + + $this->assertEqual($type, array(array('string', 'boolean'), 1, null, true)); + + $type = $this->dataDict->getPortableDeclaration(array('type' => 'varchar', 'length' => 1)); + + $this->assertEqual($type, array(array('string', 'boolean'), 1, null, false)); + } + public function testGetPortableDeclarationSupportsNativeBlobTypes() { + $type = $this->dataDict->getPortableDeclaration(array('type' => 'image')); + + $this->assertEqual($type, array(array('blob'), null, null, null)); + + $type = $this->dataDict->getPortableDeclaration(array('type' => 'varbinary')); + + $this->assertEqual($type, array(array('blob'), null, null, null)); + } + public function testGetPortableDeclarationSupportsNativeIntegerTypes() { + $type = $this->dataDict->getPortableDeclaration(array('type' => 'int')); + + $this->assertEqual($type, array(array('integer'), null, null, null)); + + $type = $this->dataDict->getPortableDeclaration(array('type' => 'int', 'length' => 1)); + + $this->assertEqual($type, array(array('integer', 'boolean'), 1, null, null)); + } + public function testGetPortableDeclarationSupportsNativeTimestampType() { + $type = $this->dataDict->getPortableDeclaration(array('type' => 'datetime')); + + $this->assertEqual($type, array(array('timestamp'), null, null, null)); + } + public function testGetPortableDeclarationSupportsNativeDecimalTypes() { + $type = $this->dataDict->getPortableDeclaration(array('type' => 'decimal')); + + $this->assertEqual($type, array(array('decimal'), null, null, null)); + + $type = $this->dataDict->getPortableDeclaration(array('type' => 'money')); + + $this->assertEqual($type, array(array('decimal'), null, null, null)); + } + public function testGetPortableDeclarationSupportsNativeFloatTypes() { + $type = $this->dataDict->getPortableDeclaration(array('type' => 'float')); + + $this->assertEqual($type, array(array('float'), null, null, null)); + + $type = $this->dataDict->getPortableDeclaration(array('type' => 'real')); + + $this->assertEqual($type, array(array('float'), null, null, null)); + + $type = $this->dataDict->getPortableDeclaration(array('type' => 'numeric')); + + $this->assertEqual($type, array(array('float'), null, null, null)); } public function testGetNativeDefinitionSupportsIntegerType() { $a = array('type' => 'integer', 'length' => 20, 'fixed' => false); diff --git a/tests/DataDict/OracleTestCase.php b/tests/DataDict/OracleTestCase.php index 17b53f924..c3019f1f3 100644 --- a/tests/DataDict/OracleTestCase.php +++ b/tests/DataDict/OracleTestCase.php @@ -1,8 +1,6 @@ 'integer', 'length' => 20, 'fixed' => false); diff --git a/tests/DataDict/PgsqlTestCase.php b/tests/DataDict/PgsqlTestCase.php index 9156e5810..71cf83a06 100644 --- a/tests/DataDict/PgsqlTestCase.php +++ b/tests/DataDict/PgsqlTestCase.php @@ -1,8 +1,6 @@ dataDict->getPortableDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 2, 'fixed' => true)); diff --git a/tests/DataDict/SqliteTestCase.php b/tests/DataDict/SqliteTestCase.php index be02e56a4..b10ae3a74 100644 --- a/tests/DataDict/SqliteTestCase.php +++ b/tests/DataDict/SqliteTestCase.php @@ -1,9 +1,5 @@ assertDeclarationType('boolean', 'boolean'); }