Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // opción 1
- class MyController extends Controller {
- protected $dep;
- public function __construct(Dependency $dep) {
- parent::__construct();
- $this->dep = $dep;
- }
- public function doStuff() {
- $this->dep->blah();
- }
- }
- // opción 2
- class MyController extends Controller {
- public function doStuff() {
- $dep = App::make('Dependency');
- $dep->blah();
- }
- }
- // test
- class MyControllerTest extends TestCase {
- public function testBlah() {
- $dep = Mockery::mock('Dependency');
- $this->app->instance('Dependency', $dep);
- // ...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement