Skip to content

Commit

Permalink
Add biginteger support.
Browse files Browse the repository at this point in the history
Remove an empty file I commited by accident, and remove the duplicated
boolean type.
  • Loading branch information
markstory committed Mar 7, 2013
1 parent 1364905 commit d4a7ee5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 69 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Type.php
Expand Up @@ -35,7 +35,6 @@ class Type {
* @var array
*/
protected static $_types = [
'boolean' => 'Cake\Model\Datasource\Database\Type\BooleanType',
'binary' => 'Cake\Model\Datasource\Database\Type\BinaryType',
'date' => 'Cake\Model\Datasource\Database\Type\DateType',
'datetime' => 'Cake\Model\Datasource\Database\Type\DateTimeType',
Expand All @@ -51,6 +50,7 @@ class Type {
protected static $_basicTypes = [
'float' => ['callback' => 'floatval'],
'integer' => ['callback' => 'intval', 'pdo' => PDO::PARAM_INT],
'biginteger' => ['callback' => 'intval', 'pdo' => PDO::PARAM_INT],
'string' => ['callback' => 'strval'],
'text' => ['callback' => 'strval'],
'boolean' => [
Expand Down
67 changes: 0 additions & 67 deletions lib/Cake/Model/Datasource/Database/Type/BooleanType.php

This file was deleted.

28 changes: 27 additions & 1 deletion lib/Cake/Test/TestCase/Model/Datasource/Database/TypeTest.php
Expand Up @@ -201,7 +201,33 @@ public function testIntegerToStatement() {
}

/**
* Tests integers from database are converted correctly to PHP
* Tests bigintegers from database are converted correctly to PHP
*
* @return void
*/
public function testBigintegerToPHP() {
$type = Type::build('biginteger');
$integer = time() * time();
$driver = $this->getMock('\Cake\Model\Datasource\Database\Driver');
$this->assertEquals($integer, $type->toPHP($integer, $driver));
$this->assertEquals($integer, $type->toPHP('' . $integer, $driver));

This comment has been minimized.

Copy link
@lorenzo

lorenzo Mar 7, 2013

Member

Maybe assertSame() to guarantee it is the same type?

This comment has been minimized.

Copy link
@markstory

markstory Mar 7, 2013

Author Member

Fixed in 4df7ecb

$this->assertEquals(3, $type->toPHP(3.57, $driver));
}

/**
* Tests bigintegers from PHP are converted correctly to statement value
*
* @return void
*/
public function testBigintegerToStatement() {
$type = Type::build('biginteger');
$integer = time() * time();
$driver = $this->getMock('\Cake\Model\Datasource\Database\Driver');
$this->assertEquals(PDO::PARAM_INT, $type->toStatement($integer, $driver));
}

/**
* Tests string from database are converted correctly to PHP
*
* @return void
*/
Expand Down

0 comments on commit d4a7ee5

Please sign in to comment.