public function testLoadFile() { $loader = new ProjectLoader3(self::$fixturesPath . '/ini'); try { $loader->loadFile('foo.yml'); $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist'); $this->assertEquals('The service file "foo.yml" is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist'); } try { $loader->loadFile('parameters.ini'); $this->fail('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file'); } catch (\Exception $e) { $this->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file'); $this->assertEquals('The service file "parameters.ini" is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file'); } $loader = new ProjectLoader3(self::$fixturesPath . '/yaml'); foreach (array('nonvalid1', 'nonvalid2') as $fixture) { try { $loader->loadFile($fixture . '.yml'); $this->fail('->load() throws an InvalidArgumentException if the loaded file does not validate'); } catch (\Exception $e) { $this->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not validate'); $this->assertStringMatchesFormat('The service file "nonvalid%d.yml" is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not validate'); } } }
public function testLoadFile() { $loader = new ProjectLoader3(self::$fixturesPath . '/ini'); try { $loader->loadFile('foo.yml'); $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); } catch (\InvalidArgumentException $e) { } try { $loader->loadFile('parameters.ini'); $this->fail('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file'); } catch (\InvalidArgumentException $e) { } $loader = new ProjectLoader3(self::$fixturesPath . '/yaml'); foreach (array('nonvalid1', 'nonvalid2') as $fixture) { try { $loader->loadFile($fixture . '.yml'); $this->fail('->load() throws an InvalidArgumentException if the loaded file does not validate'); } catch (\InvalidArgumentException $e) { } } }