$loader->
load('services6.yml'
);
$services =
$container->
getDefinitions();
$this->
assertArrayHasKey('foo',
$services, '->load() parses service elements'
);
$this->
assertFalse($services['not_shared'
]->
isShared(), '->load() parses the shared flag'
);
$this->
assertInstanceOf(Definition::
class,
$services['foo'
], '->load() converts service element to Definition instances'
);
$this->
assertEquals('FooClass',
$services['foo'
]->
getClass(), '->load() parses the class attribute'
);
$this->
assertEquals('%path%/foo.php',
$services['file'
]->
getFile(), '->load() parses the file tag'
);
$this->
assertEquals(['foo',
new Reference('foo'
),
[true, false
]],
$services['arguments'
]->
getArguments(), '->load() parses the argument tags'
);
$this->
assertEquals('sc_configure',
$services['configurator1'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals([new Reference('baz'
), 'configure'
],
$services['configurator2'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals(['BazClass', 'configureStatic'
],
$services['configurator3'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals([['setBar',
[]],
['setBar',
[]],
['setBar',
[new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")'
)]]],
$services['method_call1'
]->
getMethodCalls(), '->load() parses the method_call tag'
);
$this->
assertEquals([['setBar',
['foo',
new Reference('foo'
),
[true, false
]]]],
$services['method_call2'
]->
getMethodCalls(), '->load() parses the method_call tag'
);
$this->
assertEquals('factory',
$services['new_factory1'
]->
getFactory(), '->load() parses the factory tag'
);
$this->
assertEquals([new Reference('baz'
), 'getClass'
],
$services['new_factory2'
]->
getFactory(), '->load() parses the factory tag'
);
$this->
assertEquals(['BazClass', 'getInstance'
],
$services['new_factory3'
]->
getFactory(), '->load() parses the factory tag'
);
$this->
assertSame([null, 'getInstance'
],
$services['new_factory4'
]->
getFactory(), '->load() accepts factory tag without class'
);
$this->
assertEquals([new Reference('baz'
), '__invoke'
],
$services['new_factory5'
]->
getFactory(), '->load() accepts service reference as invokable factory'
);
$this->
assertEquals(['foo',
new Reference('baz'
)],
$services['Acme\WithShortCutArgs'
]->
getArguments(), '->load() parses short service definition'
);
$aliases =
$container->
getAliases();
$this->
assertArrayHasKey('alias_for_foo',
$aliases, '->load() parses aliases'
);
$this->
assertEquals('foo',
(string) $aliases['alias_for_foo'
], '->load() parses aliases'
);