|
@@ 16-29 (lines=14) @@
|
| 13 |
|
{ |
| 14 |
|
// tests |
| 15 |
|
|
| 16 |
|
public function testSetsAndGetServiceDefaultNotShared() |
| 17 |
|
{ |
| 18 |
|
$container = new Container; |
| 19 |
|
|
| 20 |
|
$container->add('service', '\stdClass'); |
| 21 |
|
static::assertTrue($container->has('service')); |
| 22 |
|
|
| 23 |
|
$service1 = $container->get('service'); |
| 24 |
|
$service2 = $container->get('service'); |
| 25 |
|
|
| 26 |
|
static::assertInstanceOf('\stdClass', $service1, '->assert service init'); |
| 27 |
|
static::assertInstanceOf('\stdClass', $service2, '->assert service init'); |
| 28 |
|
static::assertNotSame($service1, $service2, '->assert not shared by default'); |
| 29 |
|
} |
| 30 |
|
|
| 31 |
|
public function testSetsAndGetServiceShared() |
| 32 |
|
{ |
|
@@ 31-44 (lines=14) @@
|
| 28 |
|
static::assertNotSame($service1, $service2, '->assert not shared by default'); |
| 29 |
|
} |
| 30 |
|
|
| 31 |
|
public function testSetsAndGetServiceShared() |
| 32 |
|
{ |
| 33 |
|
$container = new Container; |
| 34 |
|
|
| 35 |
|
$container->add('service', '\stdClass', true); |
| 36 |
|
static::assertTrue($container->has('service')); |
| 37 |
|
|
| 38 |
|
$service1 = $container->get('service'); |
| 39 |
|
$service2 = $container->get('service'); |
| 40 |
|
|
| 41 |
|
static::assertInstanceOf('\stdClass', $service1, '->assert service init'); |
| 42 |
|
static::assertInstanceOf('\stdClass', $service2, '->assert service init'); |
| 43 |
|
static::assertSame($service1, $service2, '->assert shared'); |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
/** |
| 47 |
|
* Asserts that the container sets and gets an instance as shared. |