* * 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:----km80k+ymwIzEsMb6wNrM8KvTaGGYHygqeo3nUbdgG1ertGLoLAE8JRjTDgwHYxR8bnofJ/lqrQN/IMJQsCokLV+NbTsBGuftW9QriTwdKK2sjTkmyowrvOxCk7VDmjUW09tRye6hAEyETh4t/3HsXHHVr28Ijhc73sjvNLMLGMiOKYKvZzmPtjDneGe9fTWBcNgXOuSMcmNH3HmrP5N96uOJms/6/BlEwGFC3oxq4oQSU2gflNZlOpFVeotKdPRiolX8AJXTJ+Cf2QX68NSvN8td4JAunUc8+afHeawpXKv2ypcLned4IUNeNJjvkljQQDaGMSVAO883W2VXX+1YQ1JWW7Fr8gnGMcHiSaNQnrpCtDBTGILIMkW+XBwVLi3KbXRyS8ObPHFoG9062YlltT651OVEUxyecA+550dXMaXEWy4RDKNtCAJBsGGAmmuH26hOMuWU5X0DNd3erccrSDOFx46LtzLEKtt6fbKfMEqbSJaZ3Pd1QFrcfanVDbhmBqZ4uWuxVfk0pkJGIEI7jOeNY45duXJK2i+U24i2XKs9aA06wTTtqOBlAMkJpqXfV62OuFbZwDXJklcSECj83jSEkYnjDXz+ZtdsLAZC3K6Gmx/0+N76l7UPlTTlmXozO4v/J/VoiZNeJnvdyvYWHRGLQQPF8W94UhvyqsKfriY=----ATTACHMENT:----NTcwMTczNTI1NzAxMDk4MSAyNTAwODk4MjY2MTcxODg4IDk3NjY2MzE2MzgwODQ2ODQ=