Commit 7e80ad87 authored by Marco Pivetta's avatar Marco Pivetta

#869 - DBAL-1293 - Correcting tests around the invalid date/time formats to...

#869 - DBAL-1293 - Correcting tests around the invalid date/time formats to use `setExpectedException`
parent 35a4dfb2
...@@ -31,22 +31,18 @@ class DateTest extends \Doctrine\Tests\DbalTestCase ...@@ -31,22 +31,18 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
); );
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueInteger() public function testInvalidDateTimeValueInteger()
{ {
$date = 27; $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
$this->_type->convertToDatabaseValue(27, $this->_platform);
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueStdClass() public function testInvalidDateTimeValueStdClass()
{ {
$date = new \stdClass(); $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
$this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform);
} }
public function testDateConvertsToPHPValue() public function testDateConvertsToPHPValue()
......
...@@ -2,15 +2,20 @@ ...@@ -2,15 +2,20 @@
namespace Doctrine\Tests\DBAL\Types; namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform; use Doctrine\Tests\DBAL\Mocks\MockPlatform;
class DateTimeTest extends \Doctrine\Tests\DbalTestCase class DateTimeTest extends \Doctrine\Tests\DbalTestCase
{ {
protected /**
$_platform, * @var MockPlatform
$_type; */
private $_platform;
/**
* @var \Doctrine\DBAL\Types\DateTimeType
*/
private $_type;
protected function setUp() protected function setUp()
{ {
...@@ -28,22 +33,18 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase ...@@ -28,22 +33,18 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueInteger() public function testInvalidDateTimeValueInteger()
{ {
$date = 27; $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
$this->_type->convertToDatabaseValue(27, $this->_platform);
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueStdClass() public function testInvalidDateTimeValueStdClass()
{ {
$date = new \stdClass(); $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
$this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform);
} }
public function testDateTimeConvertsToPHPValue() public function testDateTimeConvertsToPHPValue()
......
...@@ -7,9 +7,15 @@ use Doctrine\Tests\DBAL\Mocks\MockPlatform; ...@@ -7,9 +7,15 @@ use Doctrine\Tests\DBAL\Mocks\MockPlatform;
class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
{ {
protected /**
$_platform, * @var MockPlatform
$_type; */
private $_platform;
/**
* @var \Doctrine\DBAL\Types\DateTimeTzType
*/
private $_type;
protected function setUp() protected function setUp()
{ {
...@@ -27,24 +33,19 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase ...@@ -27,24 +33,19 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueInteger() public function testInvalidDateTimeValueInteger()
{ {
$date = 27; $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
$this->_type->convertToDatabaseValue(27, $this->_platform);
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueStdClass() public function testInvalidDateTimeValueStdClass()
{ {
$date = new \stdClass(); $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
}
$this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform);
}
public function testDateTimeConvertsToPHPValue() public function testDateTimeConvertsToPHPValue()
{ {
......
...@@ -7,9 +7,15 @@ use Doctrine\Tests\DBAL\Mocks\MockPlatform; ...@@ -7,9 +7,15 @@ use Doctrine\Tests\DBAL\Mocks\MockPlatform;
class TimeTest extends \Doctrine\Tests\DbalTestCase class TimeTest extends \Doctrine\Tests\DbalTestCase
{ {
protected /**
$_platform, * @var MockPlatform
$_type; */
private $_platform;
/**
* @var \Doctrine\DBAL\Types\TimeType
*/
private $_type;
protected function setUp() protected function setUp()
{ {
...@@ -24,22 +30,18 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase ...@@ -24,22 +30,18 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase
); );
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueInteger() public function testInvalidDateTimeValueInteger()
{ {
$date = 27; $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
$this->_type->convertToDatabaseValue(27, $this->_platform);
} }
/**
* @expectedException \Doctrine\DBAL\Types\ConversionException
*/
public function testInvalidDateTimeValueStdClass() public function testInvalidDateTimeValueStdClass()
{ {
$date = new \stdClass(); $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
$this->_type->convertToDatabaseValue($date, $this->_platform);
$this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform);
} }
public function testTimeConvertsToPHPValue() public function testTimeConvertsToPHPValue()
......
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