Commit e5202c0f authored by Marco Pivetta's avatar Marco Pivetta

#869 - DBAL-1293 - Using a data provider for invalid type conversions

parent 7e80ad87
......@@ -30,18 +30,15 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase
);
}
public function testInvalidDateTimeValueInteger()
{
$this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue(27, $this->_platform);
}
public function testInvalidDateTimeValueStdClass()
/**
* @dataProvider invalidPHPValuesProvider
* @param mixed $value
*/
public function testInvalidTypeConversionToDatabaseValue($value)
{
$this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform);
$this->_type->convertToDatabaseValue($value, $this->_platform);
}
public function testTimeConvertsToPHPValue()
......@@ -75,4 +72,22 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime("now");
$this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform));
}
/**
* @return mixed[][]
*/
public function invalidPHPValuesProvider()
{
return [
[0],
[''],
['foo'],
['10:11:12'],
[new \stdClass()],
[$this],
[27],
[-1],
[1.2],
];
}
}
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