From 4d5f46c484512b1751be8b9e0758539efe2b8aaf Mon Sep 17 00:00:00 2001 From: Vladimir Jimenez Date: Thu, 20 Feb 2020 22:54:37 -0800 Subject: [PATCH] Add failing test for include not superseding excludes --- .../Test/Filesystem/FileExplorerTest.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/allejo/stakx/Test/Filesystem/FileExplorerTest.php b/tests/allejo/stakx/Test/Filesystem/FileExplorerTest.php index b9b3f217..2b06659d 100644 --- a/tests/allejo/stakx/Test/Filesystem/FileExplorerTest.php +++ b/tests/allejo/stakx/Test/Filesystem/FileExplorerTest.php @@ -288,4 +288,36 @@ public function testCustomTimestampMatcher() $this->assertNotContains($file->getFilename(), 'old'); } } + + public function testIncludesSupercedesExcludes() + { + vfsStream::create([ + 'dist' => [ + 'css' => [ + 'styles.css' => '', + ], + 'images' => [ + 'image1.png' => '', + 'image2.png' => '', + ], + 'js' => [ + 'main.js' => '', + ], + 'index.html' => '', + 'about.html' => '', + ], + ]); + + $explorer = FileExplorer::create($this->rootDir->url(), ['/dist\/(css|images|js)\/.+/'], ['dist'])->getFileIterator(); + $blacklist = ['index.html', 'about.html']; + $fileCount = 0; + + /** @var File $file */ + foreach ($explorer as $file) { + ++$fileCount; + $this->assertNotContains($blacklist, $file->getFilename()); + } + + $this->assertEquals(4, $fileCount); + } }