<?php
use Luticate\Utils\Dbo\LuDboDeserializeException;
use Luticate\Utils\Dbo\LuBoolDboArray;
use Luticate\Utils\Dbo\LuIntDbo;

/**
 * Created by PhpStorm.
 * User: robin
 * Date: 5/29/16
 * Time: 2:57 PM
 */

class LuBoolDboArrayTest extends \PHPUnit_Framework_TestCase
{

    public function testArrayEmpty()
    {
        $dbo = LuBoolDboArray::jsonDeserialize([]);
        $this->assertSame([], $dbo->getArray());
    }
    
    public function testArrayStringTrue()
    {
        $dbo = LuBoolDboArray::jsonDeserialize(["true"]);
        $this->assertSame([true], $dbo->getArray());
    }

    public function testArrayStringTrueCase()
    {
        $dbo = LuBoolDboArray::jsonDeserialize(["tRue"]);
        $this->assertSame([true], $dbo->getArray());
    }

    public function testArrayStringFalse()
    {
        $dbo = LuBoolDboArray::jsonDeserialize(["false"]);
        $this->assertSame([false], $dbo->getArray());
    }

    public function testArrayStringFalseCase()
    {
        $dbo = LuBoolDboArray::jsonDeserialize(["faLse"]);
        $this->assertSame([false], $dbo->getArray());
    }

    public function testArrayMultipleString()
    {
        $dbo = LuBoolDboArray::jsonDeserialize(["true", "false", "true"]);
        $this->assertSame([true, false, true], $dbo->getArray());
    }

    public function testArrayMultipleStringPlusData()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(["true", null, "true"]);
    }

    public function testArrayInt()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize([42]);
    }

    public function testArrayMultipleInt()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize([42, 24, 48]);
    }

    public function testArrayMultipleStringInt()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(["42", "24", "48"]);
    }

    public function testArrayStringInt()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(["42"]);
    }

    public function testArrayStringIntPlusData()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(["42test"]);
    }

    public function testArrayMultipleStringIntPlusData()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(["42", 42, "42test"]);
    }
    
    public function testIntString()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize("42");
    }
    
    public function testInt()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(42);
    }
    public function testIntNegativeString()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize("-42");
    }

    public function testIntNegative()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(-42);
    }

    public function testFloat()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(42.42);
    }

    public function testFloatString()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize("42.42");
    }

    public function testExponentialString()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize("42e+01");
    }

    public function testBool()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(true);
    }

    public function testBoolString()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize("true");
    }

    public function testArrayFloat()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize([42.42]);
    }

    public function testNull()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(null);
    }

    public function testObject()
    {
        $this->expectException(LuDboDeserializeException::class);
        LuBoolDboArray::jsonDeserialize(new self());
    }
}