123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- use Luticate\Utils\Dbo\LuStringDbo;
-
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 5/29/16
- * Time: 2:57 PM
- */
-
- class LuStringDboTest extends \PHPUnit_Framework_TestCase
- {
- public function testIntString()
- {
- $dbo = LuStringDbo::jsonDeserialize("42");
- $this->assertSame("42", $dbo->getString());
- }
-
- public function testInt()
- {
- $dbo = LuStringDbo::jsonDeserialize(42);
- $this->assertSame("42", $dbo->getString());
- }
- public function testIntNegativeString()
- {
- $dbo = LuStringDbo::jsonDeserialize("-42");
- $this->assertSame("-42", $dbo->getString());
- }
-
- public function testIntNegative()
- {
- $dbo = LuStringDbo::jsonDeserialize(-42);
- $this->assertSame("-42", $dbo->getString());
- }
-
- public function testStringIntPlusData()
- {
- $dbo = LuStringDbo::jsonDeserialize("42test");
- $this->assertSame("42test", $dbo->getString());
- }
-
- public function testFloat()
- {
- $dbo = LuStringDbo::jsonDeserialize(42.42);
- $this->assertSame("42.42", $dbo->getString());
- }
-
- public function testFloatString()
- {
- $dbo = LuStringDbo::jsonDeserialize("42.42");
- $this->assertSame("42.42", $dbo->getString());
- }
-
- public function testExponentialString()
- {
- $dbo = LuStringDbo::jsonDeserialize("42e+01");
- $this->assertSame("42e+01", $dbo->getString());
- }
-
- public function testBool()
- {
- $this->expectException(AbortException::class);
- LuStringDbo::jsonDeserialize(true);
- }
-
- public function testBoolString()
- {
- $dbo = LuStringDbo::jsonDeserialize("true");
- $this->assertSame("true", $dbo->getString());
- }
-
- public function testArrayEmpty()
- {
- $this->expectException(AbortException::class);
- LuStringDbo::jsonDeserialize([]);
- }
-
- public function testArrayString()
- {
- $this->expectException(AbortException::class);
- LuStringDbo::jsonDeserialize(["42"]);
- }
-
- public function testArrayInt()
- {
- $this->expectException(AbortException::class);
- LuStringDbo::jsonDeserialize([42]);
- }
-
- public function testArrayFloat()
- {
- $this->expectException(AbortException::class);
- LuStringDbo::jsonDeserialize([42.42]);
- }
-
- public function testNull()
- {
- $this->expectException(AbortException::class);
- LuStringDbo::jsonDeserialize(null);
- }
-
- public function testObject()
- {
- $this->expectException(AbortException::class);
- LuStringDbo::jsonDeserialize(new self());
- }
- }
|