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

Commit 94c39cb

Browse files
committed
#83 - a cyclic alias resolution should lead to a ServiceNotFoundException at runtime
1 parent 6e46966 commit 94c39cb

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

test/ServiceManagerTest.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@
1212
use DateTime;
1313
use PHPUnit_Framework_TestCase as TestCase;
1414
use stdClass;
15-
use Zend\ServiceManager\Exception\InvalidArgumentException;
16-
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
15+
use Zend\ServiceManager\Exception\ServiceNotFoundException;
1716
use Zend\ServiceManager\Factory\FactoryInterface;
18-
use Zend\ServiceManager\Initializer\InitializerInterface;
19-
use Zend\ServiceManager\ServiceLocatorInterface;
2017
use Zend\ServiceManager\Factory\InvokableFactory;
2118
use Zend\ServiceManager\ServiceManager;
22-
use ZendTest\ServiceManager\TestAsset\FailingAbstractFactory;
23-
use ZendTest\ServiceManager\TestAsset\FailingFactory;
2419
use ZendTest\ServiceManager\TestAsset\InvokableObject;
25-
use ZendTest\ServiceManager\TestAsset\SimpleAbstractFactory;
2620
use ZendTest\ServiceManager\TestAsset\SimpleServiceManager;
2721

2822
/**
@@ -243,4 +237,18 @@ public function testAliasToAnExplicitServiceShouldWork()
243237

244238
$this->assertSame($service, $alias);
245239
}
240+
241+
public function testCrashesOnCyclicAliases()
242+
{
243+
$serviceManager = new ServiceManager([
244+
'aliases' => [
245+
'a' => 'b',
246+
'b' => 'a',
247+
],
248+
]);
249+
250+
$this->setExpectedException(ServiceNotFoundException::class);
251+
252+
$serviceManager->get('b');
253+
}
246254
}

0 commit comments

Comments
 (0)