* * 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:----aNsykzckV2xYYkq9h7ARt5Ce1wq0QSABWAb7wpKOtws+hqFJFenNHwo1D4Db/oBakhCTjT2f+GvMxQA+MMbMuxQcac+Jnga9jd0L03lFIpTTey1RbEu9rUNmbzB6PmlWAsZeuaVc/TsjORG95RpB/mZeH18PLUfyuqbZ5HW2AE+kc8yfsjDxQp9PBRF6swe5Xdwh1MCj7OL/FRBrKgZXskxY4fFj3+byDgFgkLRiqfNc8PmpZNyezQjnWK2sq2V9NVoT4E0Jqw6+VHdDPXF4F9ITdFdNO5uqBFW/jBIIQ1qMNKguERGFmGSGzzzl6y4J82KE5b21wjOkYsZtGuSIZZspPgzP7kLUpp22MMJi89DUg3AUigsNILN4eg90sbTkPGqkbWoHoPlGjwk2hndKsjVrSriOXa3z6W7FRXrkj9aL9xOTYa8ImcS3yQm0cphb0Q5hqOX6wYJ9KVgIfX1eTX4Ww0AMTxMOxQXjsTLxvHcsqRMJC4uOiNi7Ml+0BUdpjP0w+zU8imEWOXmy/NBiaEzQcObMSSu9Ayq9PsgfMJtuJ6r7CPQJaA+qMhZpLrZWoxAJnRMlWUp9XAZsh30gxnL1nM0DkJSlWHjeyP7VfG8B9E6bg839Ry5SCfBJbZcQcLvY86IkTmV5dLNTUcaGhIUrnxqmYiDYTVVk2c1GY4A=----ATTACHMENT:----MjM5MzQ4NjA2OTA4MDg1NSA4NDgzMTMwNTAwMDE2Mjg5IDQzNjg5NTE3NDY1OTU3NTg=