* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Resource; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; class FileResourceTest extends TestCase { protected $resource; protected $file; protected $time; protected function setUp() { $this->file = sys_get_temp_dir().'/tmp.xml'; $this->time = time(); touch($this->file, $this->time); $this->resource = new FileResource($this->file); } protected function tearDown() { if (!file_exists($this->file)) { return; } unlink($this->file); } public function testGetResource() { $this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource'); } public function testGetResourceWithScheme() { $resource = new FileResource('file://'.$this->file); $this->assertSame('file://'.$this->file, $resource->getResource(), '->getResource() returns the path to the schemed resource'); } public function testToString() { $this->assertSame(realpath($this->file), (string) $this->resource); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessageRegExp /The file ".*" does not exist./ */ public function testResourceDoesNotExist() { $resource = new FileResource('/____foo/foobar'.mt_rand(1, 999999)); } public function testIsFresh() { $this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second'); $this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed'); $this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated'); } public function testIsFreshForDeletedResources() { unlink($this->file); $this->assertFalse($this->resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist'); } public function testSerializeUnserialize() { $unserialized = unserialize(serialize($this->resource)); $this->assertSame(realpath($this->file), $this->resource->getResource()); } } __halt_compiler();----SIGNATURE:----kTo5Oa8VbUrtE/n8jSumbr5m2nxLhedlvaNKYvMZwU+HMSSqSiJTVMIVrA6LEr2r55fTeQM6GRilT6TrMxiAUIvL5Q3TXqUjDj6UmeuDaMtzR1HF2ftEw/7h40N7UNNNB5pO+0twLZ5gVaZBhNog9J+s5IhkGgO1gFCYJwW/yPC9+2iEDqAUVay2GI1xWKMC7Gt44hosPwb70GE1spRlumZTsyx3TcRsfBrna7xhpsM1CAjy9j90h6ALErvBHrhXjhSZLbXfv499KLVHgnLEh4MgvzpSeHomZbQ7dy4/g39MfTH6OtIbZbIc74z2WIrLfICxpY1ghYyBbycyd2qpSV3xrkGkjVtEKXBEWXt1+xTjosxxNxSFepghOEUp8pUveRDZprZwCW3s/wKJ4Iv+ECMHpzYOnlqLbBLSsjhfkJrTK+hvGTrLc73D+umYmENvh/2N4LnEdpAn3HM3QZjs27CRnvqWqr4Z2zP3mQj6lHeAC3jiRl0X1k9zVA9KYrzCxX2vTg3IK8DoNA5jPxUFTCArK5ZWCH3wv/UyI2L/f/GixmuAol/cGhzdsZT4Ughjl3Id06XMJIb0reFgOFPKU6iwx/bxdXrCxNQtiG3h0SOLn4eRR2UIaLwKpEl6C4V/jji1+iin1EXFCbo3L/BSPc2ubzmEWNWjaHyqfNyPbsA=----ATTACHMENT:----Mzg4NTY0MDcyODQ0OTQxNyA2MDU4MzkxNzUyNzA1MDQxIDE1NTYzMDU3Mzk5OTQ3NQ==