enableCommandRunner(); $this->exec('routes'); $this->assertOutputContains('Welcome to CakePHP'); $this->assertExitCode(Shell::CODE_SUCCESS); } /** * tests exec * * @return void */ public function testExec() { $this->exec(''); $this->assertOutputContains('Welcome to CakePHP'); $this->assertExitCode(Shell::CODE_ERROR); } /** * tests a valid core command * * @return void */ public function testExecCoreCommand() { $this->exec('routes'); $this->assertOutputContains('Welcome to CakePHP'); $this->assertExitCode(Shell::CODE_SUCCESS); } /** * tests exec with an arg and an option * * @return void */ public function testExecWithArgsAndOption() { $this->exec('integration args_and_options arg --opt="some string"'); $this->assertOutputContains('arg: arg'); $this->assertOutputContains('opt: some string'); $this->assertExitCode(Shell::CODE_SUCCESS); } /** * tests exec with missing required argument * * @return void */ public function testExecWithMissingRequiredArg() { $this->exec('integration args_and_options'); $this->assertErrorContains('Missing required arguments'); $this->assertErrorContains('arg is required'); $this->assertExitCode(Shell::CODE_ERROR); } /** * tests exec with input * * @return void */ public function testExecWithInput() { $this->exec('integration bridge', ['javascript']); $this->assertErrorContains('No!'); $this->assertExitCode(Shell::CODE_ERROR); } /** * tests exec with multiple inputs * * @return void */ public function testExecWithMultipleInput() { $this->exec('integration bridge', ['cake', 'blue']); $this->assertOutputContains('You may pass'); $this->assertExitCode(Shell::CODE_SUCCESS); } /** * tests _commandStringToArgs * * @return void */ public function testCommandStringToArgs() { $result = $this->_commandStringToArgs('command --something=nothing --with-spaces="quote me on that"'); $expected = [ 'command', '--something=nothing', '--with-spaces=quote me on that' ]; $this->assertSame($expected, $result); } }