コード例 #1
0
 /**
  * @expectedException \Symfony\Component\Config\Exception\FileLoaderLoadException
  */
 public function testResolveWhenResolverCannotFindLoader()
 {
     $resolver = $this->getMock('Symfony\\Component\\Config\\Loader\\LoaderResolverInterface');
     $resolver->expects($this->once())->method('resolve')->with('FOOBAR')->will($this->returnValue(false));
     $loader = new ProjectLoader1();
     $loader->setResolver($resolver);
     $loader->resolve('FOOBAR');
 }
コード例 #2
0
 /**
  * @covers Symfony\Component\Config\Loader\Loader::resolve
  */
 public function testResolve()
 {
     $loader1 = $this->getMock('Symfony\\Component\\Config\\Loader\\LoaderInterface');
     $loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
     $resolver = new LoaderResolver(array($loader1));
     $loader = new ProjectLoader1();
     $loader->setResolver($resolver);
     $this->assertSame($loader, $loader->resolve('foo.foo'), '->resolve() finds a loader');
     $this->assertSame($loader1, $loader->resolve('foo.xml'), '->resolve() finds a loader');
     $loader1 = $this->getMock('Symfony\\Component\\Config\\Loader\\LoaderInterface');
     $loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
     $resolver = new LoaderResolver(array($loader1));
     $loader = new ProjectLoader1();
     $loader->setResolver($resolver);
     try {
         $loader->resolve('FOOBAR');
         $this->fail('->resolve() throws a FileLoaderLoadException if the resource cannot be loaded');
     } catch (FileLoaderLoadException $e) {
         $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\FileLoaderLoadException', $e, '->resolve() throws a FileLoaderLoadException if the resource cannot be loaded');
     }
 }