FileResourceTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. namespace Symfony\Tests\Components\DependencyInjection;
  10. use Symfony\Components\DependencyInjection\FileResource;
  11. class FileResourceTest extends \PHPUnit_Framework_TestCase
  12. {
  13. protected $resource;
  14. protected $file;
  15. public function setUp()
  16. {
  17. $this->file = sys_get_temp_dir().'/tmp.xml';
  18. touch($this->file);
  19. $this->resource = new FileResource($this->file);
  20. }
  21. public function tearDown()
  22. {
  23. unlink($this->file);
  24. }
  25. public function testGetResource()
  26. {
  27. $this->assertEquals($this->file, $this->resource->getResource(), '->getResource() returns the path to the resource');
  28. }
  29. public function testIsUptodate()
  30. {
  31. $this->assertTrue($this->resource->isUptodate(time() + 10), '->isUptodate() returns true if the resource has not changed');
  32. $this->assertFalse($this->resource->isUptodate(time() - 86400), '->isUptodate() returns false if the resource has been updated');
  33. $resource = new FileResource('/____foo/foobar'.rand(1, 999999));
  34. $this->assertFalse($resource->isUptodate(time()), '->isUptodate() returns false if the resource does not exist');
  35. }
  36. }