public function testServiceWithCallsDefinition() { $parser = new ServiceParser(new Config(['lorem' => 'ipsum'])); $definition = ['foo' => ['className' => 'Bar', 'calls' => [['configure'], ['configureWithParameters', ['!lorem', 'bar']], ['setRequest', ['@request']]]]]; $services = $parser->parseServices($definition); $this->assertArrayHasKey('calls', $services['foo']); $this->assertCount(3, $services['foo']['calls']); $this->assertArrayHasKey('method', $services['foo']['calls'][0]); $this->assertEquals('configure', $services['foo']['calls'][0]['method']); $this->assertArrayNotHasKey('arguments', $services['foo']['calls'][0]); $this->assertEquals('configureWithParameters', $services['foo']['calls'][1]['method']); $this->assertArrayHasKey('arguments', $services['foo']['calls'][1]); $this->assertCount(2, $services['foo']['calls'][1]['arguments']); $this->assertArrayHasKey('type', $services['foo']['calls'][1]['arguments'][0]); $this->assertArrayHasKey('value', $services['foo']['calls'][1]['arguments'][0]); $this->assertEquals('ipsum', $services['foo']['calls'][1]['arguments'][0]['value']); $this->assertArrayHasKey('type', $services['foo']['calls'][1]['arguments'][1]); $this->assertArrayHasKey('value', $services['foo']['calls'][1]['arguments'][1]); $this->assertEquals('bar', $services['foo']['calls'][1]['arguments'][1]['value']); $this->assertEquals('setRequest', $services['foo']['calls'][2]['method']); $this->assertArrayHasKey('arguments', $services['foo']['calls'][2]); $this->assertCount(1, $services['foo']['calls'][2]['arguments']); $this->assertArrayHasKey('type', $services['foo']['calls'][2]['arguments'][0]); $this->assertArrayHasKey('name', $services['foo']['calls'][2]['arguments'][0]); $this->assertEquals('service', $services['foo']['calls'][2]['arguments'][0]['type']); $this->assertEquals('request', $services['foo']['calls'][2]['arguments'][0]['name']); }
/** * @param string $path * @return $this * @throws \Symfony\Component\Yaml\Exception\ParseException * @throws \Exception */ public function load($path) { $services = $this->cache->get($path); if (null === $services) { $services = $this->parser->parseServices(Yaml::parse($path)); $this->cache->set($path, $services); } $this->services = array_merge($this->services, $services); return $this; }