You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuDateTimeDboArrayTest.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use Luticate\Utils\Dbo\LuDateDateTime;
  3. use Luticate\Utils\Dbo\LuDateTimeDboArray;
  4. use Luticate\Utils\Dbo\LuDboDeserializeException;
  5. /**
  6. * Created by PhpStorm.
  7. * User: robin
  8. * Date: 6/14/16
  9. * Time: 11:53 AM
  10. */
  11. class LuDateTimeDboArrayTest extends \PHPUnit_Framework_TestCase
  12. {
  13. public function testDateTime()
  14. {
  15. $array = [
  16. '2016-12-24 14:42:24',
  17. '2016-12-25 14:24:42'
  18. ];
  19. $dbo = LuDateTimeDboArray::jsonDeserialize($array);
  20. $this->assertSame($array, $dbo->jsonSerialize());
  21. }
  22. public function testNull()
  23. {
  24. $array = [
  25. '2016-12-24 14:42:24',
  26. null,
  27. '2016-12-25 14:24:42'
  28. ];
  29. $dbo = LuDateTimeDboArray::jsonDeserialize($array);
  30. $this->assertSame($array, $dbo->jsonSerialize());
  31. }
  32. public function testInvalid()
  33. {
  34. $array = [
  35. '2016-12-24 14:42:24',
  36. 'my date'
  37. ];
  38. $this->expectException(LuDboDeserializeException::class);
  39. LuDateTimeDboArray::jsonDeserialize($array);
  40. }
  41. }