More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / consolidation / annotated-command / tests / testCommandFileDiscovery.php
1 <?php
2 namespace Consolidation\AnnotatedCommand;
3
4 class CommandFileDiscoveryTests extends \PHPUnit_Framework_TestCase
5 {
6     function testCommandDiscovery()
7     {
8         $discovery = new CommandFileDiscovery();
9         $discovery
10           ->setSearchPattern('*CommandFile.php')
11           ->setSearchLocations(['alpha']);
12
13         chdir(__DIR__);
14         $commandFiles = $discovery->discover('.', '\Consolidation\TestUtils');
15
16         $commandFilePaths = array_keys($commandFiles);
17         $commandFileNamespaces = array_values($commandFiles);
18
19         // Ensure that the command files that we expected to
20         // find were all found.  We don't find anything in
21         // 'beta' because only 'alpha' is in the search path.
22         $this->assertContains('./src/ExampleCommandFile.php', $commandFilePaths);
23         $this->assertContains('./src/ExampleHookAllCommandFile.php', $commandFilePaths);
24         $this->assertContains('./src/alpha/AlphaCommandFile.php', $commandFilePaths);
25         $this->assertContains('./src/alpha/Inclusive/IncludedCommandFile.php', $commandFilePaths);
26
27         // Make sure that there are no additional items found.
28         $this->assertEquals(4, count($commandFilePaths));
29
30         // Ensure that the command file namespaces that we expected
31         // to be generated all match.
32         $this->assertContains('\Consolidation\TestUtils\ExampleCommandFile', $commandFileNamespaces);
33         $this->assertContains('\Consolidation\TestUtils\ExampleHookAllCommandFile', $commandFileNamespaces);
34         $this->assertContains('\Consolidation\TestUtils\alpha\AlphaCommandFile', $commandFileNamespaces);
35         $this->assertContains('\Consolidation\TestUtils\alpha\Inclusive\IncludedCommandFile', $commandFileNamespaces);
36
37         // We do not need to test for additional namespace items, because we
38         // know that the length of the array_keys must be the same as the
39         // length of the array_values.
40     }
41
42     function testDeepCommandDiscovery()
43     {
44         $discovery = new CommandFileDiscovery();
45         $discovery
46           ->setSearchPattern('*CommandFile.php')
47           ->setSearchDepth(1)
48           ->setSearchLocations([]);
49
50         chdir(__DIR__);
51         $commandFiles = $discovery->discover('.', '\Consolidation\TestUtils');
52
53         $commandFilePaths = array_keys($commandFiles);
54         $commandFileNamespaces = array_values($commandFiles);
55
56         // Ensure that the command files that we expected to
57         // find were all found. We find both 'alpha' and 'beta'
58         // items because the search locations is empty, which
59         // causes the search at the base directory to be deep.
60         // We do not find alpha/Inclusive, though, as the search
61         // depth is only 2, which excludes directories that are
62         // three levels deep.
63         $this->assertContains('./src/ExampleCommandFile.php', $commandFilePaths);
64         $this->assertContains('./src/ExampleHookAllCommandFile.php', $commandFilePaths);
65         $this->assertContains('./src/alpha/AlphaCommandFile.php', $commandFilePaths);
66         $this->assertContains('./src/beta/BetaCommandFile.php', $commandFilePaths);
67
68         // Make sure that there are no additional items found.
69         $this->assertEquals(4, count($commandFilePaths));
70
71         // Ensure that the command file namespaces that we expected
72         // to be generated all match.
73         $this->assertContains('\Consolidation\TestUtils\ExampleCommandFile', $commandFileNamespaces);
74         $this->assertContains('\Consolidation\TestUtils\ExampleHookAllCommandFile', $commandFileNamespaces);
75         $this->assertContains('\Consolidation\TestUtils\alpha\AlphaCommandFile', $commandFileNamespaces);
76         $this->assertContains('\Consolidation\TestUtils\beta\BetaCommandFile', $commandFileNamespaces);
77
78         // We do not need to test for additional namespace items, because we
79         // know that the length of the array_keys must be the same as the
80         // length of the array_values.
81     }
82 }