123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- use Luticate\Utils\Dbo\LuDboDeserializeException;
- use Luticate\Utils\Dbo\LuBoolDbo;
-
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 5/29/16
- * Time: 2:57 PM
- */
-
- class LuBoolDboTest extends \PHPUnit_Framework_TestCase
- {
- public function testBoolTrue()
- {
- $dbo = LuBoolDbo::jsonDeserialize(true);
- $this->assertSame(true, $dbo->getBool());
- }
- public function testBoolFalse()
- {
- $dbo = LuBoolDbo::jsonDeserialize(false);
- $this->assertSame(false, $dbo->getBool());
- }
-
- public function testBoolStringTrue()
- {
- $dbo = LuBoolDbo::jsonDeserialize("true");
- $this->assertSame(true, $dbo->getBool());
- }
-
- public function testBoolStringFalse()
- {
- $dbo = LuBoolDbo::jsonDeserialize("false");
- $this->assertSame(false, $dbo->getBool());
- }
-
- public function testBoolStringTrueCase()
- {
- $dbo = LuBoolDbo::jsonDeserialize("trUe");
- $this->assertSame(true, $dbo->getBool());
- }
- public function testBoolStringFalseCase()
- {
- $dbo = LuBoolDbo::jsonDeserialize("fAlse");
- $this->assertSame(false, $dbo->getBool());
- }
-
- public function testIntString()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize("42");
- }
-
- public function testInt()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize(42);
- }
- public function testIntNegativeString()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize("-42");
- }
-
- public function testIntNegative()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize(-42);
- }
-
- public function testStringIntPlusData()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize("42test");
- }
-
- public function testFloat()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize(42.42);
- }
-
- public function testFloatString()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize("42.42");
- }
-
- public function testExponentialString()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize("42e+01");
- }
-
- public function testArrayEmpty()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize([]);
- }
-
- public function testArrayString()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize(["42"]);
- }
-
- public function testArrayInt()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize([42]);
- }
-
- public function testArrayFloat()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize([42.42]);
- }
-
- public function testNull()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize(null);
- }
-
- public function testObject()
- {
- $this->expectException(LuDboDeserializeException::class);
- LuBoolDbo::jsonDeserialize(new self());
- }
- }
|