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

Commit d2b85c0

Browse files
committed
Merge branch 'hotfix/135' into develop
Forward port #135
2 parents ac9d4dc + d609ea0 commit d2b85c0

File tree

5 files changed

+38
-18
lines changed

5 files changed

+38
-18
lines changed

test/AbstractPluginManagerTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ public function createContainer(array $config = [])
3939

4040
public function testInjectCreationContextInFactories()
4141
{
42-
$invokableFactory = $this->getMock(FactoryInterface::class);
42+
$invokableFactory = $this->getMockBuilder(FactoryInterface::class)
43+
->getMock();
4344

4445
$config = [
4546
'factories' => [
4647
InvokableObject::class => $invokableFactory,
4748
],
4849
];
4950

50-
$container = $this->getMock(ContainerInterface::class);
51+
$container = $this->getMockBuilder(ContainerInterface::class)
52+
->getMock();
5153
$pluginManager = new SimplePluginManager($container, $config);
5254

5355
$invokableFactory->expects($this->once())
@@ -69,7 +71,8 @@ public function testValidateInstance()
6971
],
7072
];
7173

72-
$container = $this->getMock(ContainerInterface::class);
74+
$container = $this->getMockBuilder(ContainerInterface::class)
75+
->getMock();
7376
$pluginManager = new SimplePluginManager($container, $config);
7477

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

91-
$container = $this->getMock(ContainerInterface::class);
94+
$container = $this->getMockBuilder(ContainerInterface::class)
95+
->getMock();
9296
$pluginManager = new SimplePluginManager($container, $config);
9397

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

122-
$container = $this->getMock(ContainerInterface::class);
126+
$container = $this->getMockBuilder(ContainerInterface::class)
127+
->getMock();
123128
$pluginManager = new SimplePluginManager($container, $config);
124129

125130
$first = $pluginManager->get(InvokableObject::class, $options);

test/CommonServiceLocatorBehaviorsTrait.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ public function testBuildNeverSharesInstances()
192192

193193
public function testInitializersAreRunAfterCreation()
194194
{
195-
$initializer = $this->getMock(InitializerInterface::class);
195+
$initializer = $this->getMockBuilder(InitializerInterface::class)
196+
->getMock();
196197

197198
$serviceManager = $this->createContainer([
198199
'factories' => [
@@ -251,8 +252,10 @@ public function testConfigureCanAddNewServices()
251252

252253
public function testConfigureCanOverridePreviousSettings()
253254
{
254-
$firstFactory = $this->getMock(FactoryInterface::class);
255-
$secondFactory = $this->getMock(FactoryInterface::class);
255+
$firstFactory = $this->getMockBuilder(FactoryInterface::class)
256+
->getMock();
257+
$secondFactory = $this->getMockBuilder(FactoryInterface::class)
258+
->getMock();
256259

257260
$serviceManager = $this->createContainer([
258261
'factories' => [

test/Factory/InvokableFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class InvokableFactoryTest extends TestCase
2121
{
2222
public function testCanCreateObject()
2323
{
24-
$container = $this->getMock(ContainerInterface::class);
24+
$container = $this->getMockBuilder(ContainerInterface::class)
25+
->getMock();
2526
$factory = new InvokableFactory();
2627

2728
$object = $factory($container, InvokableObject::class, ['foo' => 'bar']);

test/Proxy/LazyServiceFactoryTest.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class LazyServiceFactoryTest extends TestCase
3939
*/
4040
protected function setUp()
4141
{
42-
$this->proxyFactory = $this->getMock(LazyLoadingValueHolderFactory::class);
42+
$this->proxyFactory = $this->getMockBuilder(LazyLoadingValueHolderFactory::class)
43+
->getMock();
4344
$servicesMap = [
4445
'fooService' => 'FooClass',
4546
];
@@ -54,10 +55,12 @@ public function testImplementsDelegatorFactoryInterface()
5455

5556
public function testThrowExceptionWhenServiceNotExists()
5657
{
57-
$callback = $this->getMock('stdClass', ['callback']);
58+
$callback = $this->getMockBuilder('stdClass')
59+
->setMethods(['callback'])
60+
->getMock();
5861
$callback->expects($this->never())
59-
->method('callback')
60-
;
62+
->method('callback');
63+
6164
$container = $this->createContainerMock();
6265

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

7477
public function testCreates()
7578
{
76-
$callback = $this->getMock('stdClass', ['callback']);
79+
$callback = $this->getMockBuilder('stdClass')
80+
->setMethods(['callback'])
81+
->getMock();
7782
$callback->expects($this->once())
7883
->method('callback')
7984
->willReturn('fooValue')
8085
;
8186
$container = $this->createContainerMock();
82-
$expectedService = $this->getMock(VirtualProxyInterface::class);
87+
$expectedService = $this->getMockBuilder(VirtualProxyInterface::class)
88+
->getMock();
8389

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

9096
$wrappedInstance = null;
91-
$result = $initializer($wrappedInstance, $this->getMock(LazyLoadingInterface::class));
97+
$result = $initializer(
98+
$wrappedInstance,
99+
$this->getMockBuilder(LazyLoadingInterface::class)->getMock()
100+
);
92101

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

114124
return $container;
115125
}

test/ServiceManagerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public function testConfigurationCanBeMerged()
4646

4747
public function testConfigurationTakesPrecedenceWhenMerged()
4848
{
49-
$factory = $this->getMock(FactoryInterface::class);
49+
$factory = $this->getMockBuilder(FactoryInterface::class)
50+
->getMock();
5051

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

0 commit comments

Comments
 (0)