*/ 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:----IOAd3N+qvti5KEIDiU4R/EQ448ogqtrwNwae4N1b3fahU19+YxwwyLuhNofc1LFpjV9XZAPPY2Nl+p7PkmD1ElHP6jV62OYnTSz7rL14fOalKR7/1/zlFvgbNNmhXLM4/L+5B9BylEDcpxvN33+skUbK852+97VHKs9KY7KsHteHu8qcMO9hg+JQkoC9pPELNZih1zZPIWRz2nGy0/n1owCrsPPd/LYq0aNq7f1Or1kccaO9UBp/c9P2huqZZWgvMmKPCAOaDZeaFypon9RsLjdj4Pilm1x7mumOxcTeUrI7PinQ6ag/cluWI0/BmHM0c/+2qOMtNBjXiTaOqrqBuu6F+BMQShkAysOJ3z9AKlgwNZefT5RpFw9i0J682xcqJRptbkGb6mcQsaYFoewk5VrjQ3UJ7X+3Gmbee5cMjav+zFmhfJpPEuAcYqvmUorp0V6vE+uNTYnEr5ruD1Pp0L94OS3hwQpP9u0x2XTCoudQF+YcPFn443sXWxtq48O1tBQIkqA/KQ3J50iBjV5GQtsU4SBzNcDrXxQG9zxcjPwiXhnQWPxgn8CD+npfj2E4CN6CEGalxhaAqzrTPL7ryPoWG2cyOhKcskolx2FLvd+udbzjlbAZ+ukWAMkA2CUJZvpWXbPILvgZRANcFPmt4/CiKGSzocmAcy4TtgD7qPQ=----ATTACHMENT:----OTMzMDM0ODEzMjE0MDE5IDkzNzk5NDk0ODY0NTA2MTggNjcwNTA2NzkzNzAwMjY3OA==