-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from UnicornGlobal/console-concern
Console and Container Concerns
- Loading branch information
Showing
6 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace AlbertCht\Lumen\Testing\Concerns; | ||
|
||
use Illuminate\Contracts\Console\Kernel; | ||
|
||
trait InteractsWithConsole | ||
{ | ||
/** | ||
* Call artisan command and return code. | ||
* | ||
* @param string $command | ||
* @param array $parameters | ||
* @return int | ||
*/ | ||
public function artisan($command, $parameters = []) | ||
{ | ||
return $this->app[Kernel::class]->call($command, $parameters); | ||
} | ||
|
||
/** | ||
* Disable mocking the console output. | ||
* | ||
* @return $this | ||
*/ | ||
protected function withoutMockingConsoleOutput() | ||
{ | ||
$this->mockConsoleOutput = false; | ||
$this->app->offsetUnset(OutputStyle::class); | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace AlbertCht\Lumen\Testing\Concerns; | ||
|
||
trait InteractsWithContainer | ||
{ | ||
/** | ||
* Register an instance of an object in the container. | ||
* | ||
* @param string $abstract | ||
* @param object $instance | ||
* @return object | ||
*/ | ||
protected function swap($abstract, $instance) | ||
{ | ||
return $this->instance($abstract, $instance); | ||
} | ||
/** | ||
* Register an instance of an object in the container. | ||
* | ||
* @param string $abstract | ||
* @param object $instance | ||
* @return object | ||
*/ | ||
protected function instance($abstract, $instance) | ||
{ | ||
$this->app->instance($abstract, $instance); | ||
return $instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters