public function testExtensions() { Loader::registerExtension(new \ProjectExtension()); $loader = new ProjectLoader3(self::$fixturesPath . '/yaml'); $config = $loader->load('services10.yml'); $services = $config->getDefinitions(); $parameters = $config->getParameters(); $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); $this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements'); $this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements'); try { $config = $loader->load('services11.yml'); $this->fail('->load() throws an InvalidArgumentException if the tag is not valid'); } catch (\Exception $e) { $this->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid'); $this->assertStringStartsWith('There is no extension able to load the configuration for "foobar.foobar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid'); } try { $config = $loader->load('services12.yml'); $this->fail('->load() throws an InvalidArgumentException if an extension is not loaded'); } catch (\Exception $e) { $this->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if an extension is not loaded'); $this->assertStringStartsWith('The "foobar" tag is not valid (in', $e->getMessage(), '->load() throws an InvalidArgumentException if an extension is not loaded'); } }
public function testExtensions() { Loader::registerExtension(new \ProjectExtension()); $loader = new ProjectLoader3(self::$fixturesPath . '/yaml'); $config = $loader->load('services10.yml'); $services = $config->getDefinitions(); $parameters = $config->getParameters(); $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); try { $config = $loader->load('services11.yml'); $this->fail('->load() throws an InvalidArgumentException if the tag is not valid'); } catch (\InvalidArgumentException $e) { } try { $config = $loader->load('services12.yml'); $this->fail('->load() throws an InvalidArgumentException if an extension is not loaded'); } catch (\InvalidArgumentException $e) { } }