-
-
Notifications
You must be signed in to change notification settings - Fork 312
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 #169 from mnapoli/bug/168
Container::has() should return false for un-mapped interfaces/abstract classes
- Loading branch information
Showing
11 changed files
with
183 additions
and
6 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
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,45 @@ | ||
<?php | ||
/** | ||
* PHP-DI | ||
* | ||
* @link http://mnapoli.github.io/PHP-DI/ | ||
* @copyright Matthieu Napoli (http://mnapoli.fr/) | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file) | ||
*/ | ||
|
||
namespace IntegrationTests\DI\Issues; | ||
|
||
use DI\ContainerBuilder; | ||
|
||
/** | ||
* Test for constructor injection of parameters that are optional, and use an | ||
* interface (or other uninstantiable) type hint. | ||
* | ||
* @link https://github.com/mnapoli/PHP-DI/pull/168 | ||
* | ||
* @coversNothing | ||
*/ | ||
class Issue168Test extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testInterfaceOptionalParameter() | ||
{ | ||
$container = ContainerBuilder::buildDevContainer(); | ||
$object = $container->get('IntegrationTests\DI\Issues\TestClass'); | ||
$this->assertInstanceOf('IntegrationTests\DI\Issues\TestClass', $object); | ||
} | ||
} | ||
|
||
class TestClass | ||
{ | ||
/** | ||
* The parameter is optional. TestInterface is not instantiable, so `null` should | ||
* be injected instead of getting an exception. | ||
*/ | ||
public function __construct(TestInterface $param = null) | ||
{ | ||
} | ||
} | ||
|
||
interface TestInterface | ||
{ | ||
} |
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