5 use Webmozart\PathUtil\Path;
7 class commandUnitCase extends UnitUnishTestCase {
9 * Assure that matching version-specific command files are loaded and others are ignored.
11 function testCommandVersionSpecific() {
12 $path = Path::join(UNISH_SANDBOX, 'commandUnitCase');
13 $major = $this->drush_major_version();
14 $major_plus1 = $major + 1;
16 // Write matched and unmatched files to the system search path.
18 Path::join($path, "$major.drush$major.inc"),
19 Path::join($path, "drush$major/drush$major.drush.inc"),
20 Path::join($path, "$major_plus1.drush$major_plus1.inc"),
21 Path::join($path, "drush$major_plus1/drush$major_plus1.drush.inc"),
23 $this->mkdir(Path::join($path, 'drush'. $major));
24 $this->mkdir(Path::join($path, 'drush'. $major_plus1));
25 foreach ($files as $file) {
28 // Written by Unish. This file is safe to delete.
29 \$GLOBALS['unish_foo'][] = '$file';
31 $return = file_put_contents($file, $contents);
33 drush_set_context('DRUSH_INCLUDE', array($path));
35 $loaded = drush_commandfile_list();
36 $this->assertContains($files[0], $loaded); //Loaded a version-specific command file.
37 $this->assertContains($files[1], $loaded); //Loaded a version-specific command directory.
38 $this->assertNotContains($files[2], $loaded); //Did not load a mismatched version-specific command file.
39 $this->assertNotContains($files[3], $loaded); //Did not load a a mismatched version-specific command directory.
43 * Assert that $command has interesting properties. Reference command by
44 * it's alias (dl) to assure that those aliases are built as expected.
46 public function testGetCommands() {
48 $commands = drush_get_commands();
49 $command = $commands['dl'];
51 $this->assertEquals('dl', current($command['aliases']));
52 $this->assertArrayHasKey('version_control', $command['engines']);
53 $this->assertArrayHasKey('package_handler', $command['engines']);
54 $this->assertArrayHasKey('release_info', $command['engines']);
55 $this->assertEquals('pm-download', $command['command']);
56 $this->assertEquals('pm', $command['commandfile']);
57 $this->assertEquals('drush_command', $command['callback']);
58 $this->assertArrayHasKey('examples', $command['sections']);
59 $this->assertTrue($command['is_alias']);
61 $command = $commands['pm-download'];
62 $this->assertArrayNotHasKey('is_alias', $command);