Skip to content

Commit

Permalink
bump cov
Browse files Browse the repository at this point in the history
  • Loading branch information
acsauk committed Nov 12, 2024
1 parent 8255062 commit 6bc4f20
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
4 changes: 4 additions & 0 deletions service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function __invoke(array $data): ArrayObject
return new ArrayObject($data, ArrayObject::ARRAY_AS_PROPS);
}


/**
* @codeCoverageIgnore
*/
public static function getMockedCombinedFormat(bool $asLpaStoreLpa): array
{
$lpaArray = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,57 @@

use Common\Entity\Casters\CastToLifeSustainingTreatment;
use EventSauce\ObjectHydrator\ObjectMapper;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use ValueError;

class CastToLifeSustainingTreatmentTest extends TestCase
{
use ProphecyTrait;

private ObjectMapper $mockHydrator;
private CastToLifeSustainingTreatment $castToLifeSustainingTreatment;
private CastToLifeSustainingTreatment $caster;

public function setUp(): void
{
$this->mockHydrator = $this->createMock(ObjectMapper::class);
$this->castToLifeSustainingTreatment = new CastToLifeSustainingTreatment();
$this->caster = new CastToLifeSustainingTreatment();
}

#[Test]
public function can_cast_life_sustaining_treatment(): void
#[DataProvider('lifeSustainingTreatmentProvider')]
public function can_cast_life_sustaining_treatment($input, $expectedOutput): void
{
$lifeSustainingTreatment = 'option-a';
$this->assertEquals(
$expectedOutput,
$this->caster->cast(
$input,
$this->prophesize(ObjectMapper::class)->reveal()
)
);
}

$expectedLifeSustainingTreatment = 'option-a';
public function lifeSustainingTreatmentProvider(): array
{
return [
['Option A', 'option-a'],
['option-a', 'option-a'],
['Option B', 'option-b'],
['option-b', 'option-b'],
];
}

$result = $this->castToLifeSustainingTreatment->cast($lifeSustainingTreatment, $this->mockHydrator);
#[Test]
public function throws_exception_on_invalid_type()
{
$this->expectException(InvalidArgumentException::class);

$this->assertEquals($expectedLifeSustainingTreatment, $result);
$this->caster->cast(
'not-a-valid-type',
$this->prophesize(ObjectMapper::class)->reveal()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@

namespace CommonTest\Service\Lpa;

use Common\Entity\LpaStore\LpaStore;
use Common\Entity\LpaStore\LpaStoreAttorney;
use Common\Entity\LpaStore\LpaStoreDonor;
use Common\Entity\LpaStore\LpaStoreTrustCorporations;
use Common\Entity\Sirius\SiriusLpa;
use Common\Entity\Sirius\SiriusLpaAttorney;
use Common\Entity\Sirius\SiriusLpaDonor;
use Common\Entity\Sirius\SiriusLpaTrustCorporations;
use Common\Enum\LpaType;
use Common\Enum\LifeSustainingTreatment;
use Common\Service\Features\FeatureEnabled;
use CommonTest\Helper\EntityTestHelper;
use DateTimeImmutable;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Common\Entity\CaseActor;
use Common\Entity\InstructionsAndPreferences\Images;
Expand Down

0 comments on commit 6bc4f20

Please sign in to comment.