36 lines
894 B
PHP
36 lines
894 B
PHP
<?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());
|
|
}
|
|
}
|