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 () {
193 $newServices->defineService(
'Car',
function () {
198 $newServices->getService(
'Car' );
202 $newServices->defineService(
'Xar',
function () {
207 $newServices->importWiring(
$services, [
'Bar' ] );
209 $this->assertNotContains(
'Bar', $newServices->getServiceNames(),
'Skip `Bar` service' );
210 $this->assertSame(
'Foo!', $newServices->getService(
'Foo' ) );
215 $this->assertContains(
'Bar', $newServices->getServiceNames(),
'Import all services' );
216 $this->assertSame(
'Bar!', $newServices->getService(
'Bar' ) );
217 $this->assertSame(
'Car!', $newServices->getService(
'Car' ),
'Use existing service instance' );
218 $this->assertSame(
'Xar!', $newServices->getService(
'Xar' ),
'Predefined services are kept' );