Commit beb2c7cf authored by Marco Pivetta's avatar Marco Pivetta

#869 - DBAL-1293 - covering remaining conversion exception logic

parent f0534f3d
......@@ -23,7 +23,41 @@ class ConversionExceptionTest extends PHPUnit_Framework_TestCase
$exception->getMessage()
);
}
/**
* @dataProvider nonScalarsProvider
*
* @param mixed $nonScalar
*/
public function testConversionFailedInvalidTypeWithNonScalar($nonScalar)
{
$exception = ConversionException::conversionFailedInvalidType($nonScalar, 'foo', ['bar', 'baz']);
$this->assertInstanceOf('Doctrine\DBAL\Types\ConversionException', $exception);
$this->assertRegExp(
'/^Could not convert PHP value of type \'(.*)\' to type \'foo\'. '
. 'Expected one of the following types: bar, baz$/',
$exception->getMessage()
);
}
/**
* @return mixed[][]
*/
public function nonScalarsProvider()
{
return [
[[]],
[['foo']],
[null],
[$this],
[new \stdClass()],
[tmpfile()],
];
}
/**
* @return mixed[][]
*/
public function scalarsProvider()
{
return [
......
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