Skimia\Foundation
  • Namespace
  • Class
  • Tree
  • Todo
  • Download

Namespaces

  • None
  • PHP
  • Skimia
    • Foundation
      • Annotations
      • Exceptions
        • Fail
      • Providers
        • Traits
      • Support
        • Traits
      • Testing
        • Traits

Classes

  • Skimia\Foundation\Annotations\BaseServiceProvider
  • Skimia\Foundation\Annotations\Scanner
  • Skimia\Foundation\FoundationServiceProvider
  • Skimia\Foundation\Testing\CommandOutput

Interfaces

  • Skimia\Foundation\Testing\TestablePromptCommandInterface

Traits

  • Skimia\Foundation\Providers\Traits\CommandLoaderTrait
  • Skimia\Foundation\Support\Traits\NamespaceClassFinderTrait
  • Skimia\Foundation\Testing\Traits\CommandTrait
  • Skimia\Foundation\Testing\Traits\TestableCommandTrait

Exceptions

  • Exception
  • LogicException
  • Skimia\Foundation\Exceptions\Fail\InvalidSuperclassUsedForTraitException
  • Skimia\Foundation\Exceptions\Fail\IsNotASubclassOfException

Functions

  • ensure_trait_used_in_subclass_of_or_fail
  • is_subclass_of_or_fail
 1 <?php
 2 
 3 namespace Skimia\Foundation\Testing\Traits;
 4 
 5 use Skimia\Foundation\Testing\CommandOutput;
 6 use Skimia\Foundation\Testing\TestablePromptCommandInterface;
 7 use Symfony\Component\Console\Input\ArrayInput;
 8 use Illuminate\Console\Command;
 9 
10 trait CommandTrait
11 {
12     /**
13      * @var null
14      */
15     protected $commandOutput = null;
16 
17     /**
18      * @return CommandOutput
19      */
20     public function getCommandOutput()
21     {
22         if (! isset($this->commandOutput)) {
23             $this->commandOutput = new CommandOutput;
24         }
25 
26         return $this->commandOutput;
27     }
28 
29     /**
30      * @param \Illuminate\Console\Command $mockedCommandObject
31      * @param array $arguments
32      * @return int
33      */
34     public function invokeCommand(Command $mockedCommandObject, $arguments = [])
35     {
36         $mockedCommandObject->setLaravel(app());
37 
38         return $mockedCommandObject->run(new ArrayInput($arguments),
39             $this->getCommandOutput());
40     }
41 
42     /**
43      * @param TestablePromptCommandInterface $commandObject
44      * @param array $arguments
45      * @return int
46      */
47     public function invokeCommandWithPrompt(TestablePromptCommandInterface $commandObject, $arguments = [])
48     {
49         $commandObject->setCommandOutput($this->getCommandOutput());
50 
51         return $this->invokeCommand($commandObject, $arguments);
52     }
53 
54     public function cleanOutputAndInvokeCommand(\Illuminate\Console\Command $commandObject, $arguments = [])
55     {
56         $this->commandOutput = null;
57 
58         return $this->invokeCommand($commandObject, $arguments);
59     }
60 }
61 
Skimia\Foundation API documentation generated by ApiGen