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

Commit dda7cbf

Browse files
committed
Make sure all services are shared by default
1 parent 98b47dd commit dda7cbf

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

src/DelegatorTestTrait.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
namespace Zend\ContainerTest;
1111

12+
use Generator;
13+
1214
trait DelegatorTestTrait
1315
{
14-
public function testDelegatorForInvokable()
16+
public function testDelegatorForInvokable() : void
1517
{
1618
$config = [
1719
'invokables' => [
@@ -30,9 +32,10 @@ public function testDelegatorForInvokable()
3032
$delegator = $container->get('foo-bar');
3133
self::assertInstanceOf(TestAsset\Delegator::class, $delegator);
3234
self::assertInstanceOf(TestAsset\Service::class, ($delegator->callback)());
35+
self::assertSame($delegator, $container->get('foo-bar'));
3336
}
3437

35-
public function testDelegatorForService()
38+
public function testDelegatorForService() : void
3639
{
3740
$myService = new TestAsset\Service();
3841
$config = [
@@ -52,9 +55,10 @@ public function testDelegatorForService()
5255
$delegator = $container->get('foo-bar');
5356
self::assertInstanceOf(TestAsset\Delegator::class, $delegator);
5457
self::assertSame($myService, ($delegator->callback)());
58+
self::assertSame($delegator, $container->get('foo-bar'));
5559
}
5660

57-
public function testDelegatorForFactory()
61+
public function testDelegatorForFactory() : void
5862
{
5963
$config = [
6064
'factories' => [
@@ -73,9 +77,10 @@ public function testDelegatorForFactory()
7377
$delegator = $container->get('foo-bar');
7478
self::assertInstanceOf(TestAsset\Delegator::class, $delegator);
7579
self::assertInstanceOf(TestAsset\Service::class, ($delegator->callback)());
80+
self::assertSame($delegator, $container->get('foo-bar'));
7681
}
7782

78-
public function testDelegatorForAliasInvokable()
83+
public function testDelegatorForAliasInvokable() : void
7984
{
8085
$config = [
8186
'aliases' => [
@@ -97,9 +102,10 @@ public function testDelegatorForAliasInvokable()
97102
$delegator = $container->get('foo-bar');
98103
self::assertInstanceOf(TestAsset\Delegator::class, $delegator);
99104
self::assertInstanceOf(TestAsset\Service::class, ($delegator->callback)());
105+
self::assertSame($delegator, $container->get('foo-bar'));
100106
}
101107

102-
public function testDelegatorForAliasService()
108+
public function testDelegatorForAliasService() : void
103109
{
104110
$myService = new TestAsset\Service();
105111
$config = [
@@ -122,9 +128,10 @@ public function testDelegatorForAliasService()
122128
$delegator = $container->get('foo-bar');
123129
self::assertInstanceOf(TestAsset\Delegator::class, $delegator);
124130
self::assertSame($myService, ($delegator->callback)());
131+
self::assertSame($delegator, $container->get('foo-bar'));
125132
}
126133

127-
public function testDelegatorForAliasFactory()
134+
public function testDelegatorForAliasFactory() : void
128135
{
129136
$config = [
130137
'aliases' => [
@@ -146,9 +153,10 @@ public function testDelegatorForAliasFactory()
146153
$delegator = $container->get('foo-bar');
147154
self::assertInstanceOf(TestAsset\Delegator::class, $delegator);
148155
self::assertInstanceOf(TestAsset\Service::class, ($delegator->callback)());
156+
self::assertSame($delegator, $container->get('foo-bar'));
149157
}
150158

151-
public function delegatorService()
159+
public function delegatorService() : Generator
152160
{
153161
yield 'invokable' => [
154162
[
@@ -172,7 +180,7 @@ public function delegatorService()
172180
/**
173181
* @dataProvider delegatorService
174182
*/
175-
public function testDelegatorMultipleDelegators(array $config)
183+
public function testDelegatorMultipleDelegators(array $config) : void
176184
{
177185
$config += [
178186
'delegators' => [
@@ -195,5 +203,6 @@ public function testDelegatorMultipleDelegators(array $config)
195203
],
196204
$service->injected
197205
);
206+
self::assertSame($service, $container->get('foo-bar'));
198207
}
199208
}

src/FactoryTestTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public function testFactory(array $config) : void
3838
$container = $this->createContainer($config);
3939

4040
self::assertTrue($container->has('service'));
41-
self::assertInstanceOf(TestAsset\Service::class, $container->get('service'));
41+
$service = $container->get('service');
42+
self::assertInstanceOf(TestAsset\Service::class, $service);
43+
self::assertSame($service, $container->get('service'));
4244
}
4345

4446
public function factoryWithName() : Generator

src/InvokableTestTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ public function testInvokableWithAlias() : void
4444
$originService = $container->get(TestAsset\Service::class);
4545
self::assertInstanceOf(TestAsset\Service::class, $originService);
4646
self::assertSame($service, $originService);
47+
self::assertSame($originService, $container->get(TestAsset\Service::class));
4748
}
4849
}

src/ServiceTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
trait ServiceTestTrait
1313
{
14-
public function testService()
14+
public function testService() : void
1515
{
1616
$service = new TestAsset\Service();
1717
$config = [

0 commit comments

Comments
 (0)