getServiceLocator([ 'foo' => function () { return 'bar'; }, 'bar' => function () { return 'baz'; }, function () { return 'dummy'; }, ]); $this->assertTrue($locator->has('foo')); $this->assertTrue($locator->has('bar')); $this->assertFalse($locator->has('dummy')); } public function testGet() { $locator = $this->getServiceLocator([ 'foo' => function () { return 'bar'; }, 'bar' => function () { return 'baz'; }, ]); $this->assertSame('bar', $locator->get('foo')); $this->assertSame('baz', $locator->get('bar')); } public function testGetDoesNotMemoize() { $i = 0; $locator = $this->getServiceLocator([ 'foo' => function () use (&$i) { ++$i; return 'bar'; }, ]); $this->assertSame('bar', $locator->get('foo')); $this->assertSame('bar', $locator->get('foo')); $this->assertSame(2, $i); } public function testThrowsOnUndefinedInternalService() { if (!$this->getExpectedException()) { $this->expectException(\Psr\Container\NotFoundExceptionInterface::class); $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.'); } $locator = $this->getServiceLocator([ 'foo' => function () use (&$locator) { return $locator->get('bar'); }, ]); $locator->get('foo'); } public function testThrowsOnCircularReference() { $this->expectException(\Psr\Container\ContainerExceptionInterface::class); $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".'); $locator = $this->getServiceLocator([ 'foo' => function () use (&$locator) { return $locator->get('bar'); }, 'bar' => function () use (&$locator) { return $locator->get('baz'); }, 'baz' => function () use (&$locator) { return $locator->get('bar'); }, ]); $locator->get('foo'); } } __halt_compiler();----SIGNATURE:----PmcIY8ujadGcKoZIrDat4zi5G2IPLGgL8hc546QmGdl+Bp9wo0TEtaBoEDdz03IuI2WV73MflQqORqzFmq6vcN87uSk2cxaQHLw1lrj6Trlb/RJTd8Q6sQ8RNy9MItH85RJmqNFkxy7+CqFBbCuGY2u9xfYilvlaOks9uvsWga0Ei9J/OFoyVVEhhttQEfjUYCf5a24AQ8eOk1xqfdFwvsmVqw55E/BF2uKhnF9jAmYfNfflK2sXeriuNnhp6P6BSXvcu+FkRKAnItdRkFUa/bz4ka0hK0wPoR1UAFHy43BYyTDdSkDAFGwWkC4XiaNWLaWBtz5Yp+GOuRJJS7jwh1svM5g6/YFfsI9nFXXDhCoTEV3pqjT5x8FFp6IqWfM3bGlk++k02IUYdghhOZmkiPDEAUmvdvFDX6LANJvxg9hsIlNaffS3IW8vsNxSqN1WHr6dCNcTi3I4sh2Nmtq/oSZBGfWqgZGO+90TMoh5Kw5BTBo7al74dcyJbIXtEuXHLcX1wNgra0Q/fMepbmf8YWhPiI1TaInOkKtOw37dv+3J9MWXFp2xizvGCd+hbjBXcfIn26pZTU1opAdTKqM9g+8X8UIo+c3gX+lenmm1B//Do8XR9Ig2ZX6Jxl+lZ6oBnZ4nYprN4Sf/HLmbda+z5oXrCgTaPgAAAyN2kv9HBLw=----ATTACHMENT:----Mjc4MTQ2NjA1MDYwNjYzNCAzNjA0MjQ3MzQ4MDIwMzI0IDIxNTM1MTY5NTA0NzAzNjY=