DateTimeToStringValueConverterTest.php 876 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Ddeboer\DataImport\Tests\ValueConverter;
  3. use Ddeboer\DataImport\ValueConverter\DateTimeToStringValueConverter;
  4. class DateTimeToStringValueConverterTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testConvertWithoutOutputFormatReturnsString()
  7. {
  8. $value = new \DateTime('2010-01-01 01:00:00');
  9. $converter = new DateTimeToStringValueConverter;
  10. $output = $converter->convert($value);
  11. $this->assertEquals('2010-01-01 01:00:00', $output);
  12. }
  13. /**
  14. * @expectedException \Ddeboer\DataImport\Exception\UnexpectedValueException
  15. * @expectedExceptionMessage Input must be DateTime object
  16. */
  17. public function testInvalidInputFormatThrowsException()
  18. {
  19. $value = '14/10/2008 09:40:20';
  20. $converter = new DateTimeToStringValueConverter;
  21. $converter->convert($value);
  22. }
  23. }