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.0KB

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