Skip to content

Commit

Permalink
coverage check
Browse files Browse the repository at this point in the history
  • Loading branch information
mike4git committed Aug 20, 2024
1 parent f01c8fc commit a06a68e
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions tests/Target/GenericTargetFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php declare(strict_types=1);

namespace Neusta\ConverterBundle\Tests\Target;

use Neusta\ConverterBundle\Target\GenericTargetFactory;
use PHPUnit\Framework\TestCase;

class GenericTargetFactoryTest extends TestCase
{
private GenericTargetFactory $factory;

/**
* @test
*/
public function create_regular_case(): void
{
$this->factory = new GenericTargetFactory(TestTarget::class);
$result = $this->factory->create();

self::assertSame(1, $result->getValue());
}

/**
* @test
*/
public function create_with_non_instnatiable_case(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Neusta\\ConverterBundle\\Tests\\Target\\TestNonInstantiableTarget" is not instantiable.');
$this->factory = new GenericTargetFactory(TestNonInstantiableTarget::class);
}

/**
* @test
*/
public function create_with_constructor_params_case(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Neusta\\ConverterBundle\\Tests\\Target\\TestWithConstructorParamsTarget" has required constructor parameters');
$this->factory = new GenericTargetFactory(TestWithConstructorParamsTarget::class);
}
}

class TestTarget
{
private int $value;

public function __construct()
{
$this->value = 1;
}

public function getValue(): int
{
return $this->value;
}
}

class TestNonInstantiableTarget
{
private int $value;

private function __construct()
{
$this->value = 1;
}
}

class TestWithConstructorParamsTarget
{
public function __construct(
private int $value,
) {
}
}

0 comments on commit a06a68e

Please sign in to comment.