Commit abc34cf0 authored by zYne's avatar zYne

new test for mysql driver

parent 4650a38d
...@@ -37,7 +37,7 @@ class Doctrine_DataDict_Firebird_TestCase extends Doctrine_UnitTestCase { ...@@ -37,7 +37,7 @@ class Doctrine_DataDict_Firebird_TestCase extends Doctrine_UnitTestCase {
public function testGetCollationFieldDeclarationReturnsValidSql() { public function testGetCollationFieldDeclarationReturnsValidSql() {
$this->assertEqual($this->dataDict->getCollationFieldDeclaration('xx'), 'COLLATE xx'); $this->assertEqual($this->dataDict->getCollationFieldDeclaration('xx'), 'COLLATE xx');
} }
public function testGetPortableTypeForUnknownDbTypeThrowsException() { public function testGetPortableDeclarationForUnknownDbTypeThrowsException() {
try { try {
$this->dataDict->getPortableDeclaration(array('type' => 'unknown')); $this->dataDict->getPortableDeclaration(array('type' => 'unknown'));
$this->fail(); $this->fail();
...@@ -45,77 +45,77 @@ class Doctrine_DataDict_Firebird_TestCase extends Doctrine_UnitTestCase { ...@@ -45,77 +45,77 @@ class Doctrine_DataDict_Firebird_TestCase extends Doctrine_UnitTestCase {
$this->pass(); $this->pass();
} }
} }
public function testGetPortableTypeSupportsNativeDateType() { public function testGetPortableDeclarationSupportsNativeDateType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'date')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'date'));
$this->assertEqual($type, array(array('date'), null, null, null)); $this->assertEqual($type, array(array('date'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeTimestampType() { public function testGetPortableDeclarationSupportsNativeTimestampType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'timestamp')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'timestamp'));
$this->assertEqual($type, array(array('timestamp'), null, null, null)); $this->assertEqual($type, array(array('timestamp'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeTimeType() { public function testGetPortableDeclarationSupportsNativeTimeType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'time')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'time'));
$this->assertEqual($type, array(array('time'), null, null, null)); $this->assertEqual($type, array(array('time'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeFloatType() { public function testGetPortableDeclarationSupportsNativeFloatType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'float')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'float'));
$this->assertEqual($type, array(array('float'), null, null, null)); $this->assertEqual($type, array(array('float'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeDoubleType() { public function testGetPortableDeclarationSupportsNativeDoubleType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'double')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'double'));
$this->assertEqual($type, array(array('float'), null, null, null)); $this->assertEqual($type, array(array('float'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeDoublePrecisionType() { public function testGetPortableDeclarationSupportsNativeDoublePrecisionType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'double precision')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'double precision'));
$this->assertEqual($type, array(array('float'), null, null, null)); $this->assertEqual($type, array(array('float'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeDfloatType() { public function testGetPortableDeclarationSupportsNativeDfloatType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'd_float')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'd_float'));
$this->assertEqual($type, array(array('float'), null, null, null)); $this->assertEqual($type, array(array('float'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeDecimalType() { public function testGetPortableDeclarationSupportsNativeDecimalType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'decimal')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'decimal'));
$this->assertEqual($type, array(array('decimal'), null, null, null)); $this->assertEqual($type, array(array('decimal'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeNumericType() { public function testGetPortableDeclarationSupportsNativeNumericType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'numeric')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'numeric'));
$this->assertEqual($type, array(array('decimal'), null, null, null)); $this->assertEqual($type, array(array('decimal'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeBlobType() { public function testGetPortableDeclarationSupportsNativeBlobType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'blob')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'blob'));
$this->assertEqual($type, array(array('blob'), null, null, null)); $this->assertEqual($type, array(array('blob'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeVarcharType() { public function testGetPortableDeclarationSupportsNativeVarcharType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'varchar')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'varchar'));
$this->assertEqual($type, array(array('string'), null, null, false)); $this->assertEqual($type, array(array('string'), null, null, false));
} }
public function testGetPortableTypeSupportsNativeCharType() { public function testGetPortableDeclarationSupportsNativeCharType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'char')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'char'));
$this->assertEqual($type, array(array('string'), null, null, true)); $this->assertEqual($type, array(array('string'), null, null, true));
} }
public function testGetPortableTypeSupportsNativeCstringType() { public function testGetPortableDeclarationSupportsNativeCstringType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'cstring')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'cstring'));
$this->assertEqual($type, array(array('string'), null, null, true)); $this->assertEqual($type, array(array('string'), null, null, true));
} }
public function testGetPortableTypeSupportsNativeBigintType() { public function testGetPortableDeclarationSupportsNativeBigintType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'bigint')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'bigint'));
$this->assertEqual($type, array(array('integer'), null, null, null)); $this->assertEqual($type, array(array('integer'), null, null, null));
} }
public function testGetPortableTypeSupportsNativeQuadType() { public function testGetPortableDeclarationSupportsNativeQuadType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'quad')); $type = $this->dataDict->getPortableDeclaration(array('type' => 'quad'));
$this->assertEqual($type, array(array('integer'), null, null, null)); $this->assertEqual($type, array(array('integer'), null, null, null));
......
<?php <?php
class Doctrine_DataDict_Mysql_TestCase extends Doctrine_Driver_UnitTestCase { /*
public function __construct() { * $Id$
parent::__construct('mysql'); *
} * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
public function testGetPortableDefinitionSupportsIntegers() { * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
$field = array('INT UNSIGNED'); * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_DataDict_Mysql_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @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_Mysql_TestCase extends Doctrine_UnitTestCase {
public function testGetCharsetFieldDeclarationReturnsValidSql() {
$this->assertEqual($this->dataDict->getCharsetFieldDeclaration('UTF-8'), 'CHARACTER SET UTF-8');
}
public function testGetCollationFieldDeclarationReturnsValidSql() {
$this->assertEqual($this->dataDict->getCollationFieldDeclaration('xx'), 'COLLATE xx');
}
public function testGetPortableDeclarationForUnknownNativeTypeThrowsException() {
try {
$this->dataDict->getPortableDeclaration(array('type' => 'some_unknown_type'));
$this->fail();
} catch(Doctrine_DataDict_Mysql_Exception $e) {
$this->pass();
}
}
public function testGetPortableDeclarationSupportsNativeIntegerTypes() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'tinyint'));
$this->assertEqual($type, array(array('integer', 'boolean'), 1, null, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'smallint unsigned'));
$this->assertEqual($type, array(array('integer'), 2, true, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'mediumint unsigned'));
$this->assertEqual($type, array(array('integer'), 3, true, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'int unsigned'));
$this->assertEqual($type, array(array('integer'), 4, true, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'integer unsigned'));
$this->assertEqual($type, array(array('integer'), 4, true, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'bigint unsigned'));
$this->assertEqual($type, array(array('integer'), 8, true, null));
} }
public function testGetPortableDeclarationSupportsNativeStringTypes() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'text'));
$this->assertEqual($type, array(array('string', 'clob'), null, null, false));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'longtext'));
$this->assertEqual($type, array(array('string', 'clob'), null, null, false));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'mediumtext'));
$this->assertEqual($type, array(array('string', 'clob'), null, null, false));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'tinytext'));
$this->assertEqual($type, array(array('string', 'clob'), null, null, false));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'char(1)'));
$this->assertEqual($type, array(array('string', 'boolean'), 1, null, true));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'varchar(1)'));
$this->assertEqual($type, array(array('string', 'boolean'), 1, null, false));
}
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 unsigned'));
$this->assertEqual($type, array(array('float'), null, true, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'double'));
$this->assertEqual($type, array(array('float'), null, null, null));
}
public function testGetPortableDeclarationSupportsNativeDateType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'date'));
$this->assertEqual($type, array(array('date'), 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' => 'unknown'));
$this->assertEqual($type, array(array('decimal'), null, null, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'numeric'));
$this->assertEqual($type, array(array('decimal'), null, null, null));
}
public function testGetPortableDeclarationSupportsNativeTimestampTypes() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'timestamp'));
$this->assertEqual($type, array(array('timestamp'), null, null, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'datetime'));
$this->assertEqual($type, array(array('timestamp'), null, null, null));
}
public function testGetPortableDeclarationSupportsNativeYearType() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'year'));
$this->assertEqual($type, array(array('integer', 'date'), null, null, null));
}
public function testGetPortableDeclarationSupportsNativeBlobTypes() {
$type = $this->dataDict->getPortableDeclaration(array('type' => 'blob'));
$this->assertEqual($type, array(array('blob'), null, null, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'mediumblob'));
$this->assertEqual($type, array(array('blob'), null, null, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'tinyblob'));
$this->assertEqual($type, array(array('blob'), null, null, null));
$type = $this->dataDict->getPortableDeclaration(array('type' => 'longblob'));
$this->assertEqual($type, array(array('blob'), null, null, null));
}
public function testGetNativeDefinitionSupportsIntegerType() { public function testGetNativeDefinitionSupportsIntegerType() {
$a = array('type' => 'integer', 'length' => 20, 'fixed' => false); $a = array('type' => 'integer', 'length' => 20, 'fixed' => false);
...@@ -91,4 +244,5 @@ class Doctrine_DataDict_Mysql_TestCase extends Doctrine_Driver_UnitTestCase { ...@@ -91,4 +244,5 @@ class Doctrine_DataDict_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
$this->assertEqual($this->dataDict->GetNativeDeclaration($a), 'TEXT'); $this->assertEqual($this->dataDict->GetNativeDeclaration($a), 'TEXT');
} }
} }
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