This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if service fetched by alias and by name directly is exactly the same service
- Loading branch information
1 parent
126e38d
commit 1ce14f5
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-container-test for the canonical source repository | ||
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com) | ||
* @license https://github.com/zendframework/zend-container-test/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zend\ContainerTest; | ||
|
||
use Generator; | ||
|
||
trait AliasTestTrait | ||
{ | ||
public function alias() : Generator | ||
{ | ||
yield 'alias-invokable' => [ | ||
[ | ||
'aliases' => ['alias' => 'service'], | ||
'invokables' => ['service' => TestAsset\Service::class], | ||
] | ||
]; | ||
yield 'alias-factory' => [ | ||
[ | ||
'aliases' => ['alias' => 'service'], | ||
'factories' => ['service' => TestAsset\Factory::class], | ||
] | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider alias | ||
*/ | ||
public function testAliasGetServiceFirst(array $config) : void | ||
{ | ||
$container = $this->createContainer($config); | ||
|
||
self::assertTrue($container->has('service')); | ||
self::assertTrue($container->has('alias')); | ||
self::assertSame($container->get('service'), $container->get('alias')); | ||
} | ||
|
||
/** | ||
* @dataProvider alias | ||
*/ | ||
public function testAliasGetAliasFirst(array $config) : void | ||
{ | ||
$container = $this->createContainer($config); | ||
|
||
self::assertTrue($container->has('alias')); | ||
self::assertTrue($container->has('service')); | ||
self::assertSame($container->get('alias'), $container->get('service')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters