Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/135'
Browse files Browse the repository at this point in the history
Close #135
  • Loading branch information
weierophinney committed Jul 15, 2016
2 parents 293a719 + d609ea0 commit 008fba0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
15 changes: 10 additions & 5 deletions test/AbstractPluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ public function createContainer(array $config = [])

public function testInjectCreationContextInFactories()
{
$invokableFactory = $this->getMock(FactoryInterface::class);
$invokableFactory = $this->getMockBuilder(FactoryInterface::class)
->getMock();

$config = [
'factories' => [
InvokableObject::class => $invokableFactory,
],
];

$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)
->getMock();
$pluginManager = new SimplePluginManager($container, $config);

$invokableFactory->expects($this->once())
Expand All @@ -69,7 +71,8 @@ public function testValidateInstance()
],
];

$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)
->getMock();
$pluginManager = new SimplePluginManager($container, $config);

// Assert no exception is triggered because the plugin manager validate ObjectWithOptions
Expand All @@ -88,7 +91,8 @@ public function testCachesInstanceByDefaultIfNoOptionsArePassed()
],
];

$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)
->getMock();
$pluginManager = new SimplePluginManager($container, $config);

$first = $pluginManager->get(InvokableObject::class);
Expand Down Expand Up @@ -119,7 +123,8 @@ public function testReturnsDiscreteInstancesIfOptionsAreProvidedRegardlessOfShar
];
$options = ['foo' => 'bar'];

$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)
->getMock();
$pluginManager = new SimplePluginManager($container, $config);

$first = $pluginManager->get(InvokableObject::class, $options);
Expand Down
9 changes: 6 additions & 3 deletions test/CommonServiceLocatorBehaviorsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public function testBuildNeverSharesInstances()

public function testInitializersAreRunAfterCreation()
{
$initializer = $this->getMock(InitializerInterface::class);
$initializer = $this->getMockBuilder(InitializerInterface::class)
->getMock();

$serviceManager = $this->createContainer([
'factories' => [
Expand Down Expand Up @@ -251,8 +252,10 @@ public function testConfigureCanAddNewServices()

public function testConfigureCanOverridePreviousSettings()
{
$firstFactory = $this->getMock(FactoryInterface::class);
$secondFactory = $this->getMock(FactoryInterface::class);
$firstFactory = $this->getMockBuilder(FactoryInterface::class)
->getMock();
$secondFactory = $this->getMockBuilder(FactoryInterface::class)
->getMock();

$serviceManager = $this->createContainer([
'factories' => [
Expand Down
3 changes: 2 additions & 1 deletion test/Factory/InvokableFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class InvokableFactoryTest extends TestCase
{
public function testCanCreateObject()
{
$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)
->getMock();
$factory = new InvokableFactory();

$object = $factory($container, InvokableObject::class, ['foo' => 'bar']);
Expand Down
26 changes: 18 additions & 8 deletions test/Proxy/LazyServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class LazyServiceFactoryTest extends TestCase
*/
protected function setUp()
{
$this->proxyFactory = $this->getMock(LazyLoadingValueHolderFactory::class);
$this->proxyFactory = $this->getMockBuilder(LazyLoadingValueHolderFactory::class)
->getMock();
$servicesMap = [
'fooService' => 'FooClass',
];
Expand All @@ -54,10 +55,12 @@ public function testImplementsDelegatorFactoryInterface()

public function testThrowExceptionWhenServiceNotExists()
{
$callback = $this->getMock('stdClass', ['callback']);
$callback = $this->getMockBuilder('stdClass')
->setMethods(['callback'])
->getMock();
$callback->expects($this->never())
->method('callback')
;
->method('callback');

$container = $this->createContainerMock();

$this->proxyFactory->expects($this->never())
Expand All @@ -73,13 +76,16 @@ public function testThrowExceptionWhenServiceNotExists()

public function testCreates()
{
$callback = $this->getMock('stdClass', ['callback']);
$callback = $this->getMockBuilder('stdClass')
->setMethods(['callback'])
->getMock();
$callback->expects($this->once())
->method('callback')
->willReturn('fooValue')
;
$container = $this->createContainerMock();
$expectedService = $this->getMock(VirtualProxyInterface::class);
$expectedService = $this->getMockBuilder(VirtualProxyInterface::class)
->getMock();

$this->proxyFactory->expects($this->once())
->method('createProxy')
Expand All @@ -88,7 +94,10 @@ function ($className, $initializer) use ($expectedService) {
$this->assertEquals('FooClass', $className, 'class name not match');

$wrappedInstance = null;
$result = $initializer($wrappedInstance, $this->getMock(LazyLoadingInterface::class));
$result = $initializer(
$wrappedInstance,
$this->getMockBuilder(LazyLoadingInterface::class)->getMock()
);

$this->assertEquals('fooValue', $wrappedInstance, 'expected callback return value');
$this->assertTrue($result, 'initializer should return true');
Expand All @@ -109,7 +118,8 @@ function ($className, $initializer) use ($expectedService) {
private function createContainerMock()
{
/** @var ContainerInterface|MockObject $container */
$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)
->getMock();

return $container;
}
Expand Down
3 changes: 2 additions & 1 deletion test/ServiceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function testConfigurationCanBeMerged()

public function testConfigurationTakesPrecedenceWhenMerged()
{
$factory = $this->getMock(FactoryInterface::class);
$factory = $this->getMockBuilder(FactoryInterface::class)
->getMock();

$factory->expects($this->once())->method('__invoke');

Expand Down

0 comments on commit 008fba0

Please sign in to comment.