This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
962 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-di for the canonical source repository | ||
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license https://github.com/zendframework/zend-di/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
namespace ZendTest\Di; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Zend\Di\ConfigProvider; | ||
use PHPUnit\Framework\Constraint\IsType; | ||
|
||
/** | ||
* @coversDefaultClass Zend\Di\Module | ||
*/ | ||
class ConfigProviderTest extends TestCase | ||
{ | ||
public function testInstanceIsInvokable() | ||
{ | ||
$this->assertInternalType(IsType::TYPE_CALLABLE, new ConfigProvider()); | ||
} | ||
|
||
public function testProvidesDependencies() | ||
{ | ||
$provider = new ConfigProvider(); | ||
$result = $provider(); | ||
|
||
$this->assertArrayHasKey('dependencies', $result); | ||
$this->assertEquals($provider->getDependencyConfig(), $result['dependencies']); | ||
} | ||
} |
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,66 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-di for the canonical source repository | ||
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license https://github.com/zendframework/zend-di/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
namespace ZendTest\Di\Container; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PHPUnit\Framework\Constraint\IsType; | ||
use Zend\Di\Container\InjectorFactory; | ||
use Psr\Container\ContainerInterface; | ||
use Zend\Di\ConfigInterface; | ||
use Zend\Di\InjectorInterface; | ||
|
||
/** | ||
* @coversDefaultClass Zend\Di\Container\InjectorFactory | ||
*/ | ||
class InjectorFactoryTest extends TestCase | ||
{ | ||
public function testFactoryIsInvokable() | ||
{ | ||
$this->assertInternalType(IsType::TYPE_CALLABLE, new InjectorFactory()); | ||
} | ||
|
||
public function testCreateWillReturnAnInjectorInstance() | ||
{ | ||
$container = $this->getMockBuilder(ContainerInterface::class)->getMockForAbstractClass(); | ||
$result = (new InjectorFactory())->create($container); | ||
|
||
$this->assertInstanceOf(InjectorInterface::class, $result); | ||
} | ||
|
||
public function testInvokeWillReturnAnInjectorInstance() | ||
{ | ||
$container = $this->getMockBuilder(ContainerInterface::class)->getMockForAbstractClass(); | ||
$factory = new InjectorFactory(); | ||
$result = $factory($container); | ||
|
||
$this->assertInstanceOf(InjectorInterface::class, $result); | ||
} | ||
|
||
public function testUsesConfigServiceFromContainer() | ||
{ | ||
$container = $this->getMockBuilder(ContainerInterface::class)->getMockForAbstractClass(); | ||
$configMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass(); | ||
$container->expects($this->atLeastOnce()) | ||
->method('has') | ||
->with(ConfigInterface::class) | ||
->willReturn(true); | ||
|
||
$container->expects($this->atLeastOnce()) | ||
->method('get') | ||
->with(ConfigInterface::class) | ||
->willReturn($configMock); | ||
|
||
$injector = (new InjectorFactory())->create($container); | ||
|
||
$reflection = new \ReflectionObject($injector); | ||
$property = $reflection->getProperty('config'); | ||
|
||
$property->setAccessible(true); | ||
$this->assertSame($configMock, $property->getValue($injector)); | ||
} | ||
} |
Oops, something went wrong.