*/ class ServiceLocatorTest extends TestCase { public function testCanAccessServices() { $pimple = new Container(); $pimple['service'] = function () { return new Fixtures\Service(); }; $locator = new ServiceLocator($pimple, array('service')); $this->assertSame($pimple['service'], $locator->get('service')); } public function testCanAccessAliasedServices() { $pimple = new Container(); $pimple['service'] = function () { return new Fixtures\Service(); }; $locator = new ServiceLocator($pimple, array('alias' => 'service')); $this->assertSame($pimple['service'], $locator->get('alias')); } /** * @expectedException \Pimple\Exception\UnknownIdentifierException * @expectedExceptionMessage Identifier "service" is not defined. */ public function testCannotAccessAliasedServiceUsingRealIdentifier() { $pimple = new Container(); $pimple['service'] = function () { return new Fixtures\Service(); }; $locator = new ServiceLocator($pimple, array('alias' => 'service')); $service = $locator->get('service'); } /** * @expectedException \Pimple\Exception\UnknownIdentifierException * @expectedExceptionMessage Identifier "foo" is not defined. */ public function testGetValidatesServiceCanBeLocated() { $pimple = new Container(); $pimple['service'] = function () { return new Fixtures\Service(); }; $locator = new ServiceLocator($pimple, array('alias' => 'service')); $service = $locator->get('foo'); } /** * @expectedException \Pimple\Exception\UnknownIdentifierException * @expectedExceptionMessage Identifier "invalid" is not defined. */ public function testGetValidatesTargetServiceExists() { $pimple = new Container(); $pimple['service'] = function () { return new Fixtures\Service(); }; $locator = new ServiceLocator($pimple, array('alias' => 'invalid')); $service = $locator->get('alias'); } public function testHasValidatesServiceCanBeLocated() { $pimple = new Container(); $pimple['service1'] = function () { return new Fixtures\Service(); }; $pimple['service2'] = function () { return new Fixtures\Service(); }; $locator = new ServiceLocator($pimple, array('service1')); $this->assertTrue($locator->has('service1')); $this->assertFalse($locator->has('service2')); } public function testHasChecksIfTargetServiceExists() { $pimple = new Container(); $pimple['service'] = function () { return new Fixtures\Service(); }; $locator = new ServiceLocator($pimple, array('foo' => 'service', 'bar' => 'invalid')); $this->assertTrue($locator->has('foo')); $this->assertFalse($locator->has('bar')); } } __halt_compiler();----SIGNATURE:----lPh3a8/QiKCUqF/p3WEzvU80AsTX0dDwqfris/cfADnGaxbyK3MFCNmVTfNE201hJnroqvMuBvauW7Alz0rv2YZ1SJAUI5pxc9dizVUFPKgL4R9Nh/CQ5pk7vmGAqhVb7YwmDKWoISoYlsWJsezTtUcLPAwxSt/lb7emlaFxfcZt+v+MYkQJeosJCHAycvS3zcwRxh6KiW7qgJG/9MCzdB9eq6VkrCJ0PXKMMHXsQWs/OpzazpGMui1nf1+JL4s3i1WMg4J2TkTyu2aRRzVewgiUsosgMazahlkLZlBIXWcqpvuUOAXvAD0KHbxdv+iWC4pD6v/4LcwSijXffHOk+PSwundPspRI3haAjui5teYaeXMMtxBV3KQuPI+IwsLmtDeKD8F/2apM0T7v2DBJkgWhCBdpUdeIaz/JI+AexaFhwXSj+0iovdIuRoAofeZhF6qlpBd4opmD9ERI+rYeg5Qmjoa5tTkrZOtboKk0mnsV3mN7WU0esq8bMEvTPXm6HxJQ7LZJDAWSDe7NwqgYExZPN/sf/iuz3YL015gQ4phmnEb1eaELBejx1TbAaxp4w3ZMmuPdvWrf0yRyhFPzW5DT0XY1BKxKBf7+f3ADXDBLJthqHXWvqCDfz/wakDDF2JMrugPHAxjf0a7QaeWfAGRc81hEp2+aKBDV2Hqvfos=----ATTACHMENT:----ODU3ODAzNzc0NzQ1NTc3OSA4MTM2Mjc3MzU2MDA1NzggNDgxMDEwMTgwNzQxMzIwMQ==