From c45b4039676445989250c9083369630050d36b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Z=C3=BClke?= Date: Sun, 28 May 2023 15:02:12 +0200 Subject: [PATCH] tests for empty or absent repository filters (#11476) The behavior in FilterRepository is currently correct, but not explicitly tested. Also add a test that ensures both filters can't be there simultaneously. --- .../Test/Repository/FilterRepositoryTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Composer/Test/Repository/FilterRepositoryTest.php b/tests/Composer/Test/Repository/FilterRepositoryTest.php index 111d58431..726cc549c 100644 --- a/tests/Composer/Test/Repository/FilterRepositoryTest.php +++ b/tests/Composer/Test/Repository/FilterRepositoryTest.php @@ -59,9 +59,22 @@ class FilterRepositoryTest extends TestCase // make sure sub-patterns are not matched without wildcard [['foo/aaa', 'foo/bbb', 'bar/xxx', 'baz/yyy'], ['exclude' => ['foo/aa', 'az/yyy']]], [[], ['only' => ['foo/aa', 'az/yyy']]], + // empty "only" means no packages allowed + [[], ['only' => []]], + // absent "only" means all packages allowed + [['foo/aaa', 'foo/bbb', 'bar/xxx', 'baz/yyy'], []], + // empty or absent "exclude" have the same effect: none + [['foo/aaa', 'foo/bbb', 'bar/xxx', 'baz/yyy'], ['exclude' => []]], + [['foo/aaa', 'foo/bbb', 'bar/xxx', 'baz/yyy'], []], ]; } + public function testBothFiltersDisallowed(): void + { + $this->expectException(\InvalidArgumentException::class); + new FilterRepository($this->arrayRepo, ['only' => [], 'exclude' => []]); + } + public function testSecurityAdvisoriesDisabledInChild(): void { $repo = new FilterRepository($this->arrayRepo, ['only' => ['foo/*']]);