From 38336cafa8c28b55f8624e1f3d5d347facd7329d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 19 Sep 2021 01:01:14 +0200 Subject: [PATCH] add tests for dot_files to FinderFactoryTest.php add test_dot_files_are_returned(): full directory content including .dot_file and .dot_dir add public function test_dot_directory_contents_are_returned(): subdirectory .dot_dir content containing .dot_file --- tests/Factories/FinderFactoryTest.php | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/Factories/FinderFactoryTest.php b/tests/Factories/FinderFactoryTest.php index 16c3129..891a695 100644 --- a/tests/Factories/FinderFactoryTest.php +++ b/tests/Factories/FinderFactoryTest.php @@ -97,6 +97,46 @@ class FinderFactoryTest extends TestCase ], $this->getFilesArray($finder)); } + public function test_dot_files_are_returned(): void + { + $this->container->set('hidden_files', []); + $this->container->set('hide_dot_files', FALSE); + + $finder = (new FinderFactory( + $this->container, + $this->config, + HiddenFiles::fromConfig($this->config) + ))(); + $finder->in($this->filePath('subdir'))->depth(0); + + $this->assertInstanceOf(Finder::class, $finder); + $this->assertEquals([ + '.dot_dir', + '.dot_file', + 'alpha.scss', + 'bravo.js', + 'charlie.bash', + 'delta.html', + 'echo.yaml', + ], $this->getFilesArray($finder)); + } + + public function test_dot_directory_contents_are_returned(): void + { + $this->container->set('hidden_files', []); + $this->container->set('hide_dot_files', FALSE); + + $finder = (new FinderFactory( + $this->container, + $this->config, + HiddenFiles::fromConfig($this->config) + ))(); + $finder->in($this->filePath('subdir/.dot_dir'))->depth(0); + + $this->assertInstanceOf(Finder::class, $finder); + $this->assertEquals(['.dot_file'], $this->getFilesArray($finder)); + } + public function test_it_throws_a_runtime_exception_with_an_invalid_sort_order(): void { $this->container->set('sort_order', 'invalid');