FileResourceTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Routing\Resource;
  11. use Symfony\Component\Routing\Resource\FileResource;
  12. class FileResourceTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testGetResource()
  15. {
  16. $file = sys_get_temp_dir().'/tmp.xml';
  17. touch($file);
  18. $resource = new FileResource($file);
  19. $this->assertEquals(realpath($file), $resource->getResource(), '->getResource() returns the path to the resource');
  20. unlink($file);
  21. }
  22. public function testIsUptodate()
  23. {
  24. $file = sys_get_temp_dir().'/tmp.xml';
  25. touch($file);
  26. $resource = new FileResource($file);
  27. $this->assertTrue($resource->isUptodate(time() + 10), '->isUptodate() returns true if the resource has not changed');
  28. $this->assertTrue(!$resource->isUptodate(time() - 86400), '->isUptodate() returns false if the resource has been updated');
  29. $resource = new FileResource('/____foo/foobar'.rand(1, 999999));
  30. $this->assertTrue(!$resource->isUptodate(time()), '->isUptodate() returns false if the resource does not exist');
  31. }
  32. }