<?php
use Luticate\Utils\Dbo\LuDateTimeDboArray;
use Luticate\Utils\Dbo\LuDboDeserializeException;

/**
 * Created by PhpStorm.
 * User: robin
 * Date: 6/14/16
 * Time: 11:53 AM
 */
class LuDateTimeDboArrayTest extends \PHPUnit_Framework_TestCase
{
    public function testDateTime()
    {
        $array = [
            '2016-12-24 14:42:24',
            '2016-12-25 14:24:42'
        ];
        $dbo = LuDateTimeDboArray::jsonDeserialize($array);
        $this->assertSame($array, $dbo->jsonSerialize());
    }

    public function testNull()
    {
        $array = [
            '2016-12-24 14:42:24',
            null,
            '2016-12-25 14:24:42'
        ];
        $dbo = LuDateTimeDboArray::jsonDeserialize($array);
        $this->assertSame($array, $dbo->jsonSerialize());
    }

    public function testInvalid()
    {
        $array = [
            '2016-12-24 14:42:24',
            'my date'
        ];
        $this->expectException(LuDboDeserializeException::class);
        LuDateTimeDboArray::jsonDeserialize($array);
    }
}