-
Notifications
You must be signed in to change notification settings - Fork 2
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 #12 from NaokiTsuchiya/feat/override-module
Enable module override when test.
- Loading branch information
Showing
16 changed files
with
319 additions
and
4 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
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ray\RayDiForLaravel\Testing; | ||
|
||
use Ray\Di\AbstractModule; | ||
use Ray\RayDiForLaravel\Application; | ||
|
||
trait OverrideModule | ||
{ | ||
protected function overrideModule(AbstractModule $module): void | ||
{ | ||
if (! property_exists($this, 'app')) { | ||
return; // @codeCoverageIgnore | ||
} | ||
|
||
if (! $this->app instanceof Application) { | ||
return; // @codeCoverageIgnore | ||
} | ||
|
||
$this->app->overrideModule($module); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ray\RayDiForLaravel\Classes; | ||
|
||
class FakeFoo implements FooInterface | ||
{ | ||
public function __invoke(): string | ||
{ | ||
return 'Fake'; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ray\RayDiForLaravel\Classes; | ||
|
||
class FakeGreeting implements GreetingInterface | ||
{ | ||
public function greet(): string | ||
{ | ||
return 'Hello, fake!'; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ray\RayDiForLaravel\Classes; | ||
|
||
class Foo implements FooInterface | ||
{ | ||
public function __invoke(): string | ||
{ | ||
return ''; | ||
} | ||
} |
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,8 @@ | ||
<?php | ||
|
||
namespace Ray\RayDiForLaravel\Classes; | ||
|
||
interface FooInterface | ||
{ | ||
public function __invoke(): string; | ||
} |
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ray\RayDiForLaravel\Classes; | ||
|
||
use Ray\Di\AbstractModule; | ||
|
||
class OtherModule extends AbstractModule | ||
{ | ||
protected function configure() | ||
{ | ||
$this->bind(FooInterface::class)->to(FakeFoo::class); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ray\RayDiForLaravel\Classes; | ||
|
||
class OverrideGreeting implements GreetingInterface | ||
{ | ||
public function greet(): string | ||
{ | ||
return 'Hello, override!'; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ray\RayDiForLaravel\Classes; | ||
|
||
use Ray\Di\AbstractModule; | ||
|
||
class OverrideGreetingModule extends AbstractModule | ||
{ | ||
|
||
protected function configure() | ||
{ | ||
$this->bind(GreetingInterface::class)->to(OverrideGreeting::class); | ||
} | ||
} |
Oops, something went wrong.