* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; class FileLocatorTest extends TestCase { /** * @dataProvider getIsAbsolutePathTests */ public function testIsAbsolutePath($path) { $loader = new FileLocator(array()); $r = new \ReflectionObject($loader); $m = $r->getMethod('isAbsolutePath'); $m->setAccessible(true); $this->assertTrue($m->invoke($loader, $path), '->isAbsolutePath() returns true for an absolute path'); } public function getIsAbsolutePathTests() { return array( array('/foo.xml'), array('c:\\\\foo.xml'), array('c:/foo.xml'), array('\\server\\foo.xml'), array('https://server/foo.xml'), array('phar://server/foo.xml'), ); } public function testLocate() { $loader = new FileLocator(__DIR__.'/Fixtures'); $this->assertEquals( __DIR__.DIRECTORY_SEPARATOR.'FileLocatorTest.php', $loader->locate('FileLocatorTest.php', __DIR__), '->locate() returns the absolute filename if the file exists in the given path' ); $this->assertEquals( __DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', $loader->locate('foo.xml', __DIR__), '->locate() returns the absolute filename if the file exists in one of the paths given in the constructor' ); $this->assertEquals( __DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', $loader->locate(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__), '->locate() returns the absolute filename if the file exists in one of the paths given in the constructor' ); $loader = new FileLocator(array(__DIR__.'/Fixtures', __DIR__.'/Fixtures/Again')); $this->assertEquals( array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'), $loader->locate('foo.xml', __DIR__, false), '->locate() returns an array of absolute filenames' ); $this->assertEquals( array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'), $loader->locate('foo.xml', __DIR__.'/Fixtures', false), '->locate() returns an array of absolute filenames' ); $loader = new FileLocator(__DIR__.'/Fixtures/Again'); $this->assertEquals( array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'), $loader->locate('foo.xml', __DIR__.'/Fixtures', false), '->locate() returns an array of absolute filenames' ); } /** * @expectedException \Symfony\Component\Config\Exception\FileLocatorFileNotFoundException * @expectedExceptionMessage The file "foobar.xml" does not exist */ public function testLocateThrowsAnExceptionIfTheFileDoesNotExists() { $loader = new FileLocator(array(__DIR__.'/Fixtures')); $loader->locate('foobar.xml', __DIR__); } /** * @expectedException \Symfony\Component\Config\Exception\FileLocatorFileNotFoundException */ public function testLocateThrowsAnExceptionIfTheFileDoesNotExistsInAbsolutePath() { $loader = new FileLocator(array(__DIR__.'/Fixtures')); $loader->locate(__DIR__.'/Fixtures/foobar.xml', __DIR__); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage An empty file name is not valid to be located. */ public function testLocateEmpty() { $loader = new FileLocator(array(__DIR__.'/Fixtures')); $loader->locate(null, __DIR__); } } __halt_compiler();----SIGNATURE:----j6vnmwPTKpGOqDnkvQmBvplPdn3qM3ToJooRz5GPhtNS3NfOlgFJHN8twUKvPFcPPJRUc49NpnxdoETDC7XUqjCAw8NTfUalmPJ9Fotxm+nbZhnt4RM0A1AayQkJ+dWTG/jZnDgwNfvCGSbprT7k6rWZ6CQSv9Yn5fyUmodA6+H8IKBcTNmCF1Z2BAIrKrrno4m2NtprcKHoZdp7th+in++hpSKH0ymUC49rziyciPa3W2eYqCwq6EL6Z8+4pMrI6bC/vHG0cuYJjpfMuVbUzI8ztahwDicMICkMt1fmnBafSOUO1y/Rrg+iwG7+uS0Z9BxqEOMyBci1DAFXhoC9NmgLs24itOCQ4Qv5DAaNAoVEgMdoZeejrYm+8Dr8Ut3OkyQq69WVmf568BhPhOnRd/kT+H813D/8YXq7pnbiJ3MfyCOgR/S4ZSA1YKeybCf3qAf4102EM73EeqfKdA3puCv5Gk/M/Z4unirbMpnYDmUWMXJyqmTiJMbr1ZJDLtatBNAsUl5JRanugwJDxp+M644HR0vQCyMS0M/h808cz3y2PZxkFcNEPdagHhHQDMHB0W6Zf2Bbh9ih4mepvKrHanBKHPyoaspFn1zU9DWsKHy4mcoTHEFgfwHrWX3TblEVzskE4JAb4LHltU4nNT2M9dsVt62Rc0Yf9paBqssoaM8=----ATTACHMENT:----ODIwMzMzNTI3NzI3NDk4IDUxNDMwMjkyNjg3OTU1ODEgNjY5MTEzNzMwNzUxMDk3Mw==