Version 1.0.0
This commit is contained in:
35
tests/PropertyTest.php
Normal file
35
tests/PropertyTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Diffhead\PHP\Dto\Tests;
|
||||
|
||||
use Diffhead\PHP\Dto\Property;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PropertyTest extends TestCase
|
||||
{
|
||||
public function testProperlyInitializes(): void
|
||||
{
|
||||
$property = new Property(131, true);
|
||||
|
||||
$this->assertSame(131, $property->value());
|
||||
$this->assertTrue($property->exists());
|
||||
|
||||
$property = new Property(null, false);
|
||||
|
||||
$this->assertNull($property->value());
|
||||
$this->assertFalse($property->exists());
|
||||
}
|
||||
|
||||
public function testValueCasting(): void
|
||||
{
|
||||
$property = new Property('1', true);
|
||||
|
||||
$this->assertSame('1', $property->toString());
|
||||
$this->assertSame(1, $property->toInt());
|
||||
$this->assertSame(1.0, $property->toFloat());
|
||||
$this->assertTrue($property->toBool());
|
||||
$this->assertSame(['1'], $property->toArray());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user