* * 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:----YhcWvT4I9Ee32F54ybznmPTPkGvML/Lm6yFra/wms6yHlgFEj9BHwjo/BrZOO0ChnTVjwLgGV7R/mfT2BgA5bMN9F0deXQo3CJGbxy+s4dXGDwUO1pWl+U7pIR6Ykz+s0E8hGCCH9UIAXzoGxARHeZOTd1o4XLrdw4gXudpT5TxYaDnJsL9GU+e73xY5BTgYKlkpC1D0RcRurrJb1I3QUA2u4bFUjMV2RpYZc7QTRwTCRtUdW4dr8LhAu6cKNGj2JAZ2zn+ZR0oVI/nY8hM2bN/h+Dyay5SWG9XwHqH97B+yaq2YnJq5AUcu5VJtdt8/aQpMXI1P+6i6bdT2vnaEWU4OEPzZPWhGbNKC1218/+tlcVugRK66UYetuV2yIyteN+saTQn10BQrCtTjz6kBUtMzhv4ep/cqQC9dBSf/Z/xdwEbRBY4usMeZBz6O6iFUTILEqyqYIYsJOKmVdW7MjMlcvkIg/6VWWYrYbmkzqmfznm3QwZMVSm3kNYH2d2XEK4Kubpd0HsfErpsukW3JRM2E7Syxo33cDSpO4sl3EbOXQNTV7//TI6Ycm+yjtElNbChGryGMAh+nnQ0hbL1brb9751gplP6Qdqo+mzIvAqmqAk2qGBu6n6eucpVGvO07rtuGPkIi+L88pV0MuaLfxp10b9+JTW9NTRCmMtGri6g=----ATTACHMENT:----ODQ3MzM2NzMyMDU3MzU1MiA1MjQ2NDQxOTczNDI3NjE5IDMxNzQ5ODY0OTQxNDA5MTE=