50 $theService =
new stdClass();
51 $name =
'TestService92834576';
56 function ( $actualLocator, $extra )
use (
$services, $theService, &$count ) {
58 PHPUnit_Framework_Assert::assertSame(
$services, $actualLocator );
59 PHPUnit_Framework_Assert::assertSame( $extra,
'Foo' );
67 $this->assertSame( 1, $count,
'instantiator should be called exactly once!' );
176 'Foo' =>
function () {
179 'Bar' =>
function () {
182 'Car' =>
function () {
189 $services->addServiceManipulator(
'Foo',
function ( $service ) {
190 return $service .
'+X';
193 $services->addServiceManipulator(
'Car',
function ( $service ) {
194 return $service .
'+X';
200 $newServices->defineService(
'Foo',
function () {
204 $newServices->addServiceManipulator(
'Foo',
function ( $service ) {
205 return $service .
'+Y';
210 $newServices->defineService(
'Car',
function () {
215 $newServices->getService(
'Car' );
219 $newServices->defineService(
'Xar',
function () {
224 $newServices->importWiring(
$services, [
'Bar' ] );
226 $this->assertNotContains(
'Bar', $newServices->getServiceNames(),
'Skip `Bar` service' );
227 $this->assertSame(
'Foo!+Y+X', $newServices->getService(
'Foo' ) );
232 $this->assertContains(
'Bar', $newServices->getServiceNames(),
'Import all services' );
233 $this->assertSame(
'Bar!', $newServices->getService(
'Bar' ) );
234 $this->assertSame(
'Car!', $newServices->getService(
'Car' ),
'Use existing service instance' );
235 $this->assertSame(
'Xar!', $newServices->getService(
'Xar' ),
'Predefined services are kept' );
349 $theService1 =
new stdClass();
350 $theService2 =
new stdClass();
351 $name =
'TestService92834576';
355 function ( $actualLocator, $extra )
use (
$services, $theService1 ) {
356 PHPUnit_Framework_Assert::assertSame(
$services, $actualLocator );
357 PHPUnit_Framework_Assert::assertSame(
'Foo', $extra );
365 $theService, $actualLocator, $extra
369 PHPUnit_Framework_Assert::assertSame( $theService1, $theService );
370 PHPUnit_Framework_Assert::assertSame(
$services, $actualLocator );
371 PHPUnit_Framework_Assert::assertSame(
'Foo', $extra );
377 $this->assertSame( $theService2,
$services->getService(
$name ) );