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