Browse Source

fix tests, add numeric type for unsigned

imsamurai 12 years ago
parent
commit
e35823e72a

+ 1 - 1
lib/Cake/Model/Datasource/Database/Mysql.php

@@ -91,7 +91,7 @@ class Mysql extends DboSource {
 			'value' => 'UNSIGNED', 'quote' => false, 'join' => ' ', 'column' => false, 'position' => 'afterDefault',
 			'noVal' => true,
 			'options' => array(true),
-			'types' => array('integer', 'float', 'biginteger')
+			'types' => array('integer', 'float', 'biginteger', 'numeric')
 		)
 	);
 

+ 23 - 15
lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php

@@ -3166,14 +3166,9 @@ class MysqlTest extends CakeTestCase {
  * 
  * @dataProvider buildColumnUnsignedProvider
  */
-	public function testBuildColumnUnsigned($data, $expected) {
-		$restore = $this->Dbo->columns;
-		$this->Dbo->columns = array('string' => 1, 'integer' => 1, 'float' => 1, 'biginteger' => 1, 'any' => 1);
-
+	public function testBuildColumnUnsigned($data, $expected) {//debug($this->Dbo->columns);
 		$result = $this->Dbo->buildColumn($data);
 		$this->assertEquals($expected, $result);
-		
-		$this->Dbo->columns = $restore;
 	}
 	
 /**
@@ -3188,18 +3183,20 @@ class MysqlTest extends CakeTestCase {
 				array(
 					'name' => 'testName',
 					'type' => 'integer',
+					'length' => 11,
 					'unsigned' => true
 				),
-				'`testName`  UNSIGNED'
+				'`testName` int(11) UNSIGNED'
 			),
 			//set #1
 			array(
 				array(
 					'name' => 'testName',
 					'type' => 'biginteger',
+					'length' => 20,
 					'unsigned' => true
 				),
-				'`testName`  UNSIGNED'
+				'`testName` bigint(20) UNSIGNED'
 			),
 			//set #2
 			array(
@@ -3208,43 +3205,54 @@ class MysqlTest extends CakeTestCase {
 					'type' => 'float',
 					'unsigned' => true
 				),
-				'`testName`  UNSIGNED'
+				'`testName` float UNSIGNED'
 			),
 			//set #3
 			array(
 				array(
 					'name' => 'testName',
 					'type' => 'string',
+					'length' => 255,
 					'unsigned' => true
 				),
-				'`testName` '
+				'`testName` varchar(255)'
 			),
 			//set #4
 			array(
 				array(
 					'name' => 'testName',
-					'type' => 'any',
+					'type' => 'date',
 					'unsigned' => true
 				),
-				'`testName` '
+				'`testName` date'
 			),
 			//set #5
 			array(
 				array(
 					'name' => 'testName',
-					'type' => 'any',
+					'type' => 'date',
 					'unsigned' => false
 				),
-				'`testName` '
+				'`testName` date'
 			),
 			//set #6
 			array(
 				array(
 					'name' => 'testName',
 					'type' => 'integer',
+					'length' => 11,
 					'unsigned' => false
 				),
-				'`testName` '
+				'`testName` int(11)'
+			),
+			//set #7
+			array(
+				array(
+					'name' => 'testName',
+					'type' => 'numeric',
+					'unsigned' => true
+				),
+				'`testName` decimal UNSIGNED'
 			)
 		);
 	}