Skip to content

Commit

Permalink
fix duplicate test
Browse files Browse the repository at this point in the history
  • Loading branch information
reinfi committed Oct 21, 2023
1 parent cd2aad1 commit 717c52b
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions test/Unit/Service/Extractor/Factory/ExtractorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,57 +112,6 @@ public function testItReturnsArrayOfExtractorsDefinedInConfig(): void
self::assertContainsOnlyInstancesOf(ExtractorInterface::class, $chain);
}

public function testItReturnsArrayOfExtractorsDefinedInConfig(): void
{
$isPhp8OrAbove = version_compare(PHP_VERSION, '8.0.0') >= 0;

$moduleConfig = new Config([
'extractor' => [
YamlExtractor::class,
],
]);

$yamlExtractor = $this->prophesize(YamlExtractor::class);
$annotationExtractor = $this->prophesize(AnnotationExtractor::class);
$attributeExtractor = $this->prophesize(AttributeExtractor::class);
$container = $this->prophesize(ContainerInterface::class);

$container->get(ModuleConfig::class)
->willReturn($moduleConfig->toArray())
->shouldBeCalled();
$container->get(YamlExtractor::class)
->willReturn($yamlExtractor->reveal())
->shouldBeCalled();
$container->get(AnnotationExtractor::class)
->willReturn($annotationExtractor->reveal())
->shouldBeCalled();
$container->get(AttributeExtractor::class)
->willReturn($attributeExtractor->reveal())
->shouldBeCalledTimes($isPhp8OrAbove ? 1 : 0);

$factory = new ExtractorFactory();

$extractor = $factory($container->reveal());

self::assertInstanceOf(ExtractorChain::class, $extractor);

$reflectionClass = new ReflectionClass($extractor);
$chainProperty = $reflectionClass->getProperty('chain');
$chainProperty->setAccessible(true);

$chain = $chainProperty->getValue($extractor);

self::assertTrue(is_array($chain));

if ($isPhp8OrAbove) {
self::assertCount(3, $chain);
} else {
self::assertCount(2, $chain);
}

self::assertContainsOnlyInstancesOf(ExtractorInterface::class, $chain);
}

public function testItReturnsAnnotationExtractorIfNoneDefined(): void
{
$moduleConfig = new Config([]);
Expand Down

0 comments on commit 717c52b

Please sign in to comment.