creating configuration and type casting

This commit is contained in:
Your Name
2024-10-18 22:27:29 +03:00
parent 7744d22039
commit 705a50d681
14 changed files with 253 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\Casting;
use App\Casting\Type\IntegerType;
use App\Casting\Type\StringType;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(MapperType::class)]
final class MapperTypeTest extends TestCase
{
public function testGetStringType(): void
{
$type = (new MapperType(MapperType::STRING))->create('value');
self::assertInstanceOf(
$type,
StringType::class,
);
}
public function testGetIntegerType(): void
{
$type = (new MapperType(MapperType::INTEGER))->create(1);
self::assertInstanceOf(
$type,
IntegerType::class,
);
}
public function testGetIntType(): void
{
$type = (new MapperType(MapperType::INT))->create(1);
self::assertInstanceOf(
$type,
IntegerType::class,
);
}
}

View File

@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Configuration;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(Configuration::class)]
final class ConfigurationTest extends TestCase
{
public function testUseConfiguration(): void
{
$configuration = new Configuration();
$configuration->set('test-option', 'test-value');
self::assertEquals(
$configuration->get('test-option'),
'test-value',
);
}
}

1
tests/benchmark.php Normal file
View File

@@ -0,0 +1 @@
<?php