FileResourceTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. require_once __DIR__.'/../../../bootstrap.php';
  10. use Symfony\Components\DependencyInjection\FileResource;
  11. $t = new LimeTest(5);
  12. // ->getResource()
  13. $t->diag('->getResource()');
  14. $file = sys_get_temp_dir().'/tmp.xml';
  15. touch($file);
  16. $resource = new FileResource($file);
  17. $t->is($resource->getResource(), $file, '->getResource() returns the path to the resource');
  18. // ->isUptodate()
  19. $t->diag('->isUptodate()');
  20. sleep(1);
  21. $t->ok($resource->isUptodate(), '->isUptodate() returns true if the resource has not changed');
  22. $t->ok($resource->isUptodate(time() + 10), '->isUptodate() returns true if the resource has not changed');
  23. $t->ok(!$resource->isUptodate(time() - 86400), '->isUptodate() returns false if the resource has been updated');
  24. unlink($file);
  25. $resource = new FileResource('/____foo/foobar'.rand(1, 999999));
  26. $t->ok(!$resource->isUptodate(), '->isUptodate() returns false if the resource does not exist');