| @@ 24-32 (lines=9) @@ | ||
| 21 | $this->runner = new \Robo\Runner('\Robo\RoboFileFixture'); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function testNoOptionsNoConfiguration() |
|
| 25 | { |
|
| 26 | // Run without any config and without any options |
|
| 27 | $argv = ['placeholder', 'test:simple-list']; |
|
| 28 | $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 29 | ||
| 30 | $this->guy->seeInOutput("a: '1'"); |
|
| 31 | $this->guy->seeInOutput("b: '2'"); |
|
| 32 | } |
|
| 33 | ||
| 34 | public function testOptionsButNoConfiguration() |
|
| 35 | { |
|
| @@ 34-42 (lines=9) @@ | ||
| 31 | $this->guy->seeInOutput("b: '2'"); |
|
| 32 | } |
|
| 33 | ||
| 34 | public function testOptionsButNoConfiguration() |
|
| 35 | { |
|
| 36 | // Set one option, but provide no config |
|
| 37 | $argv = ['placeholder', 'test:simple-list', '--b=3']; |
|
| 38 | $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 39 | ||
| 40 | $this->guy->seeInOutput("a: '1'"); |
|
| 41 | $this->guy->seeInOutput("b: '3'"); |
|
| 42 | } |
|
| 43 | ||
| 44 | public function testWithConfigurationButNoOptions() |
|
| 45 | { |
|
| @@ 56-63 (lines=8) @@ | ||
| 53 | $this->guy->seeInOutput("b: '5'"); |
|
| 54 | } |
|
| 55 | ||
| 56 | public function testHelpWithoutConfiguration() |
|
| 57 | { |
|
| 58 | $argv = ['placeholder', 'help', 'test:simple-list']; |
|
| 59 | $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 60 | ||
| 61 | $this->guy->seeInOutput('[default: "1"]'); |
|
| 62 | $this->guy->seeInOutput('[default: "2"]'); |
|
| 63 | } |
|
| 64 | ||
| 65 | public function testHelpWithConfigurationButNoOptions() |
|
| 66 | { |
|
| @@ 91-102 (lines=12) @@ | ||
| 88 | $this->guy->seeOutputEquals($expected); |
|
| 89 | } |
|
| 90 | ||
| 91 | public function testCommandEventHook() |
|
| 92 | { |
|
| 93 | $argv = ['placeholder', 'test:command-event']; |
|
| 94 | $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 95 | ||
| 96 | $expected = <<<EOT |
|
| 97 | This is the command-event hook for the test:command-event command. |
|
| 98 | This is the main method for the test:command-event command. |
|
| 99 | This is the post-command hook for the test:command-event command. |
|
| 100 | EOT; |
|
| 101 | $this->guy->seeInOutput($expected); |
|
| 102 | } |
|
| 103 | ||
| 104 | public function testCustomEventHook() |
|
| 105 | { |
|
| @@ 104-111 (lines=8) @@ | ||
| 101 | $this->guy->seeInOutput($expected); |
|
| 102 | } |
|
| 103 | ||
| 104 | public function testCustomEventHook() |
|
| 105 | { |
|
| 106 | $argv = ['placeholder', 'test:custom-event']; |
|
| 107 | $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 108 | ||
| 109 | $expected = 'one,two'; |
|
| 110 | $this->guy->seeInOutput($expected); |
|
| 111 | } |
|
| 112 | ||
| 113 | public function testRoboStaticRunMethod() |
|
| 114 | { |
|
| @@ 121-127 (lines=7) @@ | ||
| 118 | $this->guy->seeInOutput('Some text in section one.'); |
|
| 119 | } |
|
| 120 | ||
| 121 | public function testDeploy() |
|
| 122 | { |
|
| 123 | $argv = ['placeholder', 'test:deploy', '--simulate']; |
|
| 124 | $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 125 | $this->guy->seeInOutput('[Simulator] Simulating Remote\\Ssh(\'mysite.com\', null)'); |
|
| 126 | $this->guy->seeInOutput('[Simulator] Running ssh mysite.com \'cd "/var/www/somesite" && git pull\''); |
|
| 127 | } |
|
| 128 | ||
| 129 | public function testRunnerTryError() |
|
| 130 | { |
|
| @@ 129-136 (lines=8) @@ | ||
| 126 | $this->guy->seeInOutput('[Simulator] Running ssh mysite.com \'cd "/var/www/somesite" && git pull\''); |
|
| 127 | } |
|
| 128 | ||
| 129 | public function testRunnerTryError() |
|
| 130 | { |
|
| 131 | $argv = ['placeholder', 'test:error']; |
|
| 132 | $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 133 | ||
| 134 | $this->guy->seeInOutput('[Exec] Running ls xyzzy'); |
|
| 135 | $this->assertTrue($result > 0); |
|
| 136 | } |
|
| 137 | ||
| 138 | public function testRunnerTrySimulatedError() |
|
| 139 | { |
|
| @@ 138-145 (lines=8) @@ | ||
| 135 | $this->assertTrue($result > 0); |
|
| 136 | } |
|
| 137 | ||
| 138 | public function testRunnerTrySimulatedError() |
|
| 139 | { |
|
| 140 | $argv = ['placeholder', 'test:error', '--simulate']; |
|
| 141 | $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 142 | ||
| 143 | $this->guy->seeInOutput('Simulating Exec'); |
|
| 144 | $this->assertEquals(0, $result); |
|
| 145 | } |
|
| 146 | ||
| 147 | public function testRunnerTryException() |
|
| 148 | { |
|
| @@ 147-154 (lines=8) @@ | ||
| 144 | $this->assertEquals(0, $result); |
|
| 145 | } |
|
| 146 | ||
| 147 | public function testRunnerTryException() |
|
| 148 | { |
|
| 149 | $argv = ['placeholder', 'test:exception', '--task']; |
|
| 150 | $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 151 | ||
| 152 | $this->guy->seeInOutput('Task failed with an exception'); |
|
| 153 | $this->assertEquals(1, $result); |
|
| 154 | } |
|
| 155 | ||
| 156 | public function testInitCommand() |
|
| 157 | { |
|
| @@ 173-180 (lines=8) @@ | ||
| 170 | $this->assertContains('class RoboTestClass', $commandContents); |
|
| 171 | } |
|
| 172 | ||
| 173 | public function testTasksStopOnFail() |
|
| 174 | { |
|
| 175 | $argv = ['placeholder', 'test:stop-on-fail']; |
|
| 176 | $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); |
|
| 177 | ||
| 178 | $this->guy->seeInOutput('['); |
|
| 179 | $this->assertTrue($result > 0); |
|
| 180 | } |
|
| 181 | ||
| 182 | public function testInvalidRoboDirectory() |
|
| 183 | { |
|