Commit dc3844e1 authored by Christian Heinrich's avatar Christian Heinrich Committed by Roman S. Borschel

Fixed #DDC-571

parent ee04b31d
...@@ -25,7 +25,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; ...@@ -25,7 +25,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
/** /**
* Type that maps an SQL INT to a PHP integer. * Type that maps an SQL INT to a PHP integer.
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
*/ */
...@@ -43,9 +43,9 @@ class IntegerType extends Type ...@@ -43,9 +43,9 @@ class IntegerType extends Type
public function convertToPHPValue($value, AbstractPlatform $platform) public function convertToPHPValue($value, AbstractPlatform $platform)
{ {
return (int) $value; return (null === $value) ? null : (int) $value;
} }
public function getBindingType() public function getBindingType()
{ {
return \PDO::PARAM_INT; return \PDO::PARAM_INT;
......
...@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type; ...@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks; use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
class IntegerTest extends \Doctrine\Tests\DbalTestCase class IntegerTest extends \Doctrine\Tests\DbalTestCase
{ {
protected protected
...@@ -19,10 +19,14 @@ class IntegerTest extends \Doctrine\Tests\DbalTestCase ...@@ -19,10 +19,14 @@ class IntegerTest extends \Doctrine\Tests\DbalTestCase
$this->_type = Type::getType('integer'); $this->_type = Type::getType('integer');
} }
public function testDecimalConvertsToPHPValue() public function testIntegerConvertsToPHPValue()
{ {
$this->assertTrue( $this->assertTrue(
is_integer($this->_type->convertToPHPValue('1', $this->_platform)) is_integer($this->_type->convertToPHPValue('1', $this->_platform))
); );
$this->assertTrue(
is_null($this->_type->convertToPHPValue(null, $this->_platform))
);
} }
} }
\ No newline at end of file
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