FileResourceTest.php 1.4 KB

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