|
16 | 16 | use MoodlePluginCI\Tests\Fake\Process\DummyExecute; |
17 | 17 | use MoodlePluginCI\Tests\FilesystemTestCase; |
18 | 18 | use Symfony\Component\Console\Application; |
| 19 | +use Symfony\Component\Console\Output\OutputInterface; |
19 | 20 | use Symfony\Component\Console\Tester\CommandTester; |
20 | 21 |
|
21 | 22 | class AddPluginCommandTest extends FilesystemTestCase |
@@ -51,12 +52,36 @@ public function testExecute() |
51 | 52 | public function testExecuteWithClone() |
52 | 53 | { |
53 | 54 | $commandTester = $this->getCommandTester(); |
| 55 | + // Execute with verbosity, so process helper outputs command line. |
54 | 56 | $commandTester->execute([ |
55 | 57 | '--clone' => 'https://github.com/user/moodle-mod_foo.git', |
56 | 58 | '--storage' => $this->tempDir.'/plugins', |
57 | | - ]); |
| 59 | + ], ['verbosity' => OutputInterface::VERBOSITY_VERY_VERBOSE]); |
| 60 | + |
| 61 | + $this->assertSame(0, $commandTester->getStatusCode()); |
| 62 | + $this->assertContains('git clone --depth 1 https://github.com/user/moodle-mod_foo.git', |
| 63 | + $commandTester->getDisplay()); |
| 64 | + $this->assertTrue(is_dir($this->tempDir.'/plugins')); |
| 65 | + $this->assertFileExists($this->tempDir.'/.env'); |
| 66 | + $this->assertSame( |
| 67 | + sprintf("EXTRA_PLUGINS_DIR=%s/plugins\n", realpath($this->tempDir)), |
| 68 | + file_get_contents($this->tempDir.'/.env') |
| 69 | + ); |
| 70 | + } |
| 71 | + |
| 72 | + public function testExecuteWithCloneAndBranch() |
| 73 | + { |
| 74 | + $commandTester = $this->getCommandTester(); |
| 75 | + // Execute with verbosity, so process helper outputs command line. |
| 76 | + $commandTester->execute([ |
| 77 | + '--clone' => 'https://github.com/user/moodle-mod_foo.git', |
| 78 | + '--branch' => 'dev', |
| 79 | + '--storage' => $this->tempDir.'/plugins', |
| 80 | + ], ['verbosity' => OutputInterface::VERBOSITY_VERY_VERBOSE]); |
58 | 81 |
|
59 | 82 | $this->assertSame(0, $commandTester->getStatusCode()); |
| 83 | + $this->assertContains('git clone --depth 1 --branch dev https://github.com/user/moodle-mod_foo.git', |
| 84 | + $commandTester->getDisplay()); |
60 | 85 | $this->assertTrue(is_dir($this->tempDir.'/plugins')); |
61 | 86 | $this->assertFileExists($this->tempDir.'/.env'); |
62 | 87 | $this->assertSame( |
|
0 commit comments