Skip to content

Commit

Permalink
fix tests, add numeric type for unsigned
Browse files Browse the repository at this point in the history
  • Loading branch information
imsamurai committed Nov 13, 2013
1 parent 5a40944 commit e35823e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -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')
)
);

Expand Down
38 changes: 23 additions & 15 deletions lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -3166,14 +3166,9 @@ public function testBuildColumnBadType() {
*
* @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;
}

/**
Expand All @@ -3188,18 +3183,20 @@ public function buildColumnUnsignedProvider() {
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(
Expand All @@ -3208,43 +3205,54 @@ public function buildColumnUnsignedProvider() {
'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'
)
);
}
Expand Down

0 comments on commit e35823e

Please sign in to comment.