Пример #1
0
 public function testLoadFile()
 {
     $loader = new ProjectLoader3(new ContainerBuilder(), 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(new ContainerBuilder(), 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');
         }
     }
 }