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