diff --git a/tests/OpenApiTestCase.php b/tests/OpenApiTestCase.php index 7b75819d..9980ba0a 100644 --- a/tests/OpenApiTestCase.php +++ b/tests/OpenApiTestCase.php @@ -241,11 +241,12 @@ public static function processors(array $strip = []): array return $processors; } - public function analysisFromFixtures(array $files, array $processors = [], ?AnalyserInterface $analyzer = null): Analysis + public function analysisFromFixtures(array $files, array $processors = [], ?AnalyserInterface $analyzer = null, array $config = []): Analysis { $analysis = new Analysis([], $this->getContext()); (new Generator($this->getTrackingLogger())) + ->setConfig($config) ->setAnalyser($analyzer ?: $this->getAnalyzer()) ->setProcessorPipeline(new Pipeline($processors)) ->generate($this->fixtures($files), $analysis, false); diff --git a/tests/Processors/CleanUnusedComponentsTest.php b/tests/Processors/CleanUnusedComponentsTest.php index bcc0fcb6..ab3caa6c 100644 --- a/tests/Processors/CleanUnusedComponentsTest.php +++ b/tests/Processors/CleanUnusedComponentsTest.php @@ -7,29 +7,28 @@ namespace OpenApi\Tests\Processors; use OpenApi\Generator; -use OpenApi\Processors\CleanUnusedComponents; use OpenApi\Tests\OpenApiTestCase; class CleanUnusedComponentsTest extends OpenApiTestCase { public static function countCases(): iterable { - $defaultProcessors = static::processors([CleanUnusedComponents::class]); + $configEnable = ['cleanUnusedComponents' => ['enabled' => true]]; return [ - 'var-default' => [$defaultProcessors, 'UsingVar.php', 2, 5], - 'var-clean' => [array_merge($defaultProcessors, [new CleanUnusedComponents(true)]), 'UsingVar.php', 0, 2], - 'unreferenced-default' => [$defaultProcessors, 'Unreferenced.php', 2, 11], - 'unreferenced-clean' => [array_merge($defaultProcessors, [new CleanUnusedComponents(true)]), 'Unreferenced.php', 0, 5], + 'var-default' => [[], 'UsingVar.php', 2, 5], + 'var-clean' => [$configEnable, 'UsingVar.php', 0, 2], + 'unreferenced-default' => [[], 'Unreferenced.php', 2, 11], + 'unreferenced-clean' => [$configEnable, 'Unreferenced.php', 0, 5], ]; } /** * @dataProvider countCases */ - public function testCounts(array $processors, string $fixture, int $expectedSchemaCount, int $expectedAnnotationCount): void + public function testCounts(array $config, string $fixture, int $expectedSchemaCount, int $expectedAnnotationCount): void { - $analysis = $this->analysisFromFixtures([$fixture], $processors); + $analysis = $this->analysisFromFixtures([$fixture], static::processors(), null, $config); if ($expectedSchemaCount === 0) { $this->assertTrue(Generator::isDefault($analysis->openapi->components->schemas));