Mercurial > hg > isophonics-drupal-site
view vendor/consolidation/annotated-command/tests/testCommandFileDiscovery.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line source
<?php namespace Consolidation\AnnotatedCommand; class CommandFileDiscoveryTests extends \PHPUnit_Framework_TestCase { function testCommandDiscovery() { $discovery = new CommandFileDiscovery(); $discovery ->setSearchPattern('*CommandFile.php') ->setSearchLocations(['alpha']); chdir(__DIR__); $commandFiles = $discovery->discover('.', '\Consolidation\TestUtils'); $commandFilePaths = array_keys($commandFiles); $commandFileNamespaces = array_values($commandFiles); // Ensure that the command files that we expected to // find were all found. We don't find anything in // 'beta' because only 'alpha' is in the search path. $this->assertContains('./src/ExampleCommandFile.php', $commandFilePaths); $this->assertContains('./src/ExampleHookAllCommandFile.php', $commandFilePaths); $this->assertContains('./src/alpha/AlphaCommandFile.php', $commandFilePaths); $this->assertContains('./src/alpha/Inclusive/IncludedCommandFile.php', $commandFilePaths); // Make sure that there are no additional items found. $this->assertEquals(4, count($commandFilePaths)); // Ensure that the command file namespaces that we expected // to be generated all match. $this->assertContains('\Consolidation\TestUtils\ExampleCommandFile', $commandFileNamespaces); $this->assertContains('\Consolidation\TestUtils\ExampleHookAllCommandFile', $commandFileNamespaces); $this->assertContains('\Consolidation\TestUtils\alpha\AlphaCommandFile', $commandFileNamespaces); $this->assertContains('\Consolidation\TestUtils\alpha\Inclusive\IncludedCommandFile', $commandFileNamespaces); // We do not need to test for additional namespace items, because we // know that the length of the array_keys must be the same as the // length of the array_values. } function testDeepCommandDiscovery() { $discovery = new CommandFileDiscovery(); $discovery ->setSearchPattern('*CommandFile.php') ->setSearchDepth(1) ->setSearchLocations([]); chdir(__DIR__); $commandFiles = $discovery->discover('.', '\Consolidation\TestUtils'); $commandFilePaths = array_keys($commandFiles); $commandFileNamespaces = array_values($commandFiles); // Ensure that the command files that we expected to // find were all found. We find both 'alpha' and 'beta' // items because the search locations is empty, which // causes the search at the base directory to be deep. // We do not find alpha/Inclusive, though, as the search // depth is only 2, which excludes directories that are // three levels deep. $this->assertContains('./src/ExampleCommandFile.php', $commandFilePaths); $this->assertContains('./src/ExampleHookAllCommandFile.php', $commandFilePaths); $this->assertContains('./src/alpha/AlphaCommandFile.php', $commandFilePaths); $this->assertContains('./src/beta/BetaCommandFile.php', $commandFilePaths); // Make sure that there are no additional items found. $this->assertEquals(4, count($commandFilePaths)); // Ensure that the command file namespaces that we expected // to be generated all match. $this->assertContains('\Consolidation\TestUtils\ExampleCommandFile', $commandFileNamespaces); $this->assertContains('\Consolidation\TestUtils\ExampleHookAllCommandFile', $commandFileNamespaces); $this->assertContains('\Consolidation\TestUtils\alpha\AlphaCommandFile', $commandFileNamespaces); $this->assertContains('\Consolidation\TestUtils\beta\BetaCommandFile', $commandFileNamespaces); // We do not need to test for additional namespace items, because we // know that the length of the array_keys must be the same as the // length of the array_values. } }