Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
namespace Ddeboer\DataImport\Tests\ValueConverter;

use Ddeboer\DataImport\ValueConverter\DateTimeToStringValueConverter;
use Ddeboer\DataImport\ValueConverter\DateTimeValueConverter;

class DateTimeToStringValueConverterTest extends \PHPUnit_Framework_TestCase
{
public function testConvertWithoutOutputFormatReturnsString()
{
$value = new \DateTime('2010-01-01 01:00:00');
$converter = new DateTimeToStringValueConverter;
$output = $converter->convert($value);
$converter = new DateTimeValueConverter();
$output = $converter->__invoke($value);
$this->assertEquals('2010-01-01 01:00:00', $value->format('Y-m-d H:i:s'));
}

public function testInvalidInputFormatThrowsException()
{
$value = '14/10/2008 09:40:20';
$converter = new DateTimeToStringValueConverter;
$converter = new DateTimeValueConverter();
$this->setExpectedException("UnexpectedValueException", "Input must be DateTime object.");
$converter->convert($value);
$converter->__invoke($value);
}
}