Skip to content

Commit 8f13f2d

Browse files
1blankz7sebastianbergmann
authored andcommitted
[#48] Remove false and null from paths array in factory
1 parent ca2670d commit 8f13f2d

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/Factory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ protected function getPathsAfterResolvingWildcards(array $paths): array
7878
}
7979
}
8080

81-
return $_paths;
81+
return \array_filter($_paths);
8282
}
8383
}

tests/FactoryTest.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace SebastianBergmann\FileIterator;
4+
5+
use org\bovigo\vfs\vfsStream;
6+
use org\bovigo\vfs\vfsStreamDirectory;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class FactoryTest extends TestCase
10+
{
11+
/**
12+
* @var string
13+
*/
14+
private $root;
15+
16+
/**
17+
* @var Factory
18+
*/
19+
private $factory;
20+
21+
public function setUp()
22+
{
23+
$this->root = __DIR__;
24+
$this->factory = new Factory;
25+
}
26+
27+
public function testFindFilesInTestDirectory()
28+
{
29+
$iterator = $this->factory->getFileIterator($this->root, 'Test.php');
30+
$files = \iterator_to_array($iterator);
31+
32+
$this->assertGreaterThanOrEqual(1, count($files));
33+
}
34+
35+
public function testFindFilesWithExcludedNonExistingSubdirectory()
36+
{
37+
$iterator = $this->factory->getFileIterator($this->root, 'Test.php', '', [$this->root . '/nonExistingDir']);
38+
$files = \iterator_to_array($iterator);
39+
40+
$this->assertGreaterThanOrEqual(1, count($files));
41+
}
42+
}

0 commit comments

Comments
 (0)