File tree Expand file tree Collapse file tree 8 files changed +110
-2
lines changed Expand file tree Collapse file tree 8 files changed +110
-2
lines changed Original file line number Diff line number Diff line change 42
42
43
43
class WhyBlockCommandController extends Command
44
44
{
45
- private const ALL_DEPS = 'include-all-dependencies ' ;
46
- private const ROOT_DEPS = 'include-root-dependencies ' ;
47
45
private const LEGACY_ANNOTATION = 'include-legacy-annotations ' ;
48
46
private const FAIL_ON_ERROR = 'fail-on-error ' ;
49
47
private const OUTPUT_FORMAT = 'format ' ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * @copyright 2021 Navarr Barnier. All Rights Reserved.
5
+ */
6
+
7
+ declare (strict_types=1 );
8
+
9
+ namespace Navarr \Depends \Test \ScopeDeterminer ;
10
+
11
+ use Navarr \Depends \ScopeDeterminer \DirectoryScopeDeterminer ;
12
+ use Navarr \Depends \ScopeDeterminer \PhpFileFinder ;
13
+ use PHPUnit \Framework \TestCase ;
14
+
15
+ class DirectoryScopeDeterminerTest extends TestCase
16
+ {
17
+ public function testDirectoryIsGivenToPhpFileFinder (): void
18
+ {
19
+ $ dir = uniqid ();
20
+ $ finder = $ this ->createMock (PhpFileFinder::class);
21
+ $ finder ->expects ($ this ->once ())
22
+ ->method ('findAll ' )
23
+ ->with ($ dir )
24
+ ->willReturn ([]);
25
+
26
+ $ determiner = new DirectoryScopeDeterminer ($ finder , $ dir );
27
+ $ determiner ->getFiles ();
28
+ }
29
+
30
+ public function testResultOfPhpFileFinderIsProvidedBack (): void
31
+ {
32
+ $ results = [
33
+ uniqid (),
34
+ uniqid ()
35
+ ];
36
+
37
+ $ finder = $ this ->createMock (PhpFileFinder::class);
38
+ $ finder ->method ('findAll ' )
39
+ ->willReturn ($ results );
40
+
41
+ $ determiner = new DirectoryScopeDeterminer ($ finder , uniqid ());
42
+ $ this ->assertEquals ($ results , $ determiner ->getFiles ());
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * @copyright 2021 Navarr Barnier. All Rights Reserved.
5
+ */
6
+
7
+ declare (strict_types=1 );
8
+
9
+ namespace Navarr \Depends \Test \ScopeDeterminer ;
10
+
11
+ use DI \Container ;
12
+ use Navarr \Depends \ScopeDeterminer \PhpFileFinder ;
13
+ use PHPUnit \Framework \TestCase ;
14
+
15
+ class PhpFileFinderTest extends TestCase
16
+ {
17
+ public function testFindAll ()
18
+ {
19
+ $ directory = implode (
20
+ DIRECTORY_SEPARATOR ,
21
+ [
22
+ __DIR__ ,
23
+ '.. ' ,
24
+ '_data ' ,
25
+ 'phpFileFinder ' ,
26
+ ]
27
+ );
28
+
29
+ $ files = array_map (
30
+ 'realpath ' ,
31
+ [
32
+ $ directory . DIRECTORY_SEPARATOR . 'file1.php ' ,
33
+ $ directory . DIRECTORY_SEPARATOR . 'recursion1/file4.php ' ,
34
+ $ directory . DIRECTORY_SEPARATOR . 'recursion1/anotherFile.php ' ,
35
+ $ directory . DIRECTORY_SEPARATOR . 'recursion1/recursion2/file3.php ' ,
36
+ $ directory . DIRECTORY_SEPARATOR . 'recursion1/recursion2/recursion3/file2.php ' ,
37
+ ]
38
+ );
39
+
40
+ $ container = new Container ();
41
+ $ finder = $ container ->get (PhpFileFinder::class);
42
+ $ results = $ finder ->findAll ($ directory );
43
+
44
+ $ this ->assertIsArray ($ results );
45
+ $ this ->assertCount (5 , $ results );
46
+
47
+ foreach ($ files as $ file ) {
48
+ $ this ->assertContains ($ file , $ results );
49
+ }
50
+ }
51
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // a php file in the base directory searched
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // another file in the first directory deep
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // a file one directory deep
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // a file two directories deep
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // a file several directories deep
You can’t perform that action at this time.
0 commit comments