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

Commit 0db33e6

Browse files
committed
Added services configuration test
1 parent e0a3186 commit 0db33e6

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ following traits into your test case:
4040
- `Zend\ContainerTest\AliasTestTrait` - to support `aliases` configuration,
4141
- `Zend\ContainerTest\FactoryTestTrait` - to support `factories` configuration,
4242
- `Zend\ContainerTest\InvokableTestTrait` - to support `invokables` configuration,
43+
- `Zend\ContainerTest\ServiceTestTrait` - to support `services` configuration,
4344
- `Zend\ContainerTest\SharedTestTrait` - to support `shared` and `shared_by_default` configurations,
4445

4546
or use `Zend\ContainerTest\AllTestTrait` to support whole `zend-servicemanager` configuration.

src/AllTestTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ trait AllTestTrait
1414
use AliasTestTrait;
1515
use FactoryTestTrait;
1616
use InvokableTestTrait;
17+
use ServiceTestTrait;
1718
use SharedTestTrait;
1819
}

src/ServiceTestTrait.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-container-test for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-container-test/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Zend\ContainerTest;
11+
12+
trait ServiceTestTrait
13+
{
14+
public function testService()
15+
{
16+
$service = new TestAsset\Service();
17+
$config = [
18+
'services' => [
19+
'foo-bar' => $service,
20+
],
21+
];
22+
23+
$container = $this->createContainer($config);
24+
25+
self::assertTrue($container->has('foo-bar'));
26+
self::assertSame($service, $container->get('foo-bar'));
27+
}
28+
}

0 commit comments

Comments
 (0)