public function testGetOutputDir_output_option_high_priority()
 {
     $path = 'path/to/commands';
     $output = '../tests';
     $cmd = m::mock('Consolet\\Command');
     $cmd->shouldReceive('option')->with('output')->andReturn($output);
     $cmd->shouldReceive('getWorkingPath')->andReturn(__DIR__);
     $gen = new CommandGenerator($cmd);
     $gen->setPathCommands($path);
     $expected_path = __DIR__ . DIRECTORY_SEPARATOR . $output;
     $this->assertSame($expected_path, $gen->getOutputDir());
 }
Example #2
0
 public function fire()
 {
     $namespace = $this->option('namespace');
     if (!is_null($namespace)) {
         $namespace = ' namespace ' . $namespace . ';';
     }
     $replacement = [];
     $replacement['{{class}}'] = $this->generator->getCommandClassName();
     $replacement['{{namespace}}'] = (string) $namespace;
     $this->generator->setPathCommands($this->config('paths.commands'));
     $this->comment('output: ' . $this->generator->getOutputPath());
     if ($this->generator->execute($replacement)) {
         $this->info('Command created successfully.');
     } else {
         $this->error('Command already exists.');
     }
 }