FileResourceTest.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Assetic package, an OpenSky project.
  4. *
  5. * (c) 2010-2012 OpenSky Project Inc
  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 Assetic\Test\Factory\Resource;
  11. use Assetic\Factory\Resource\FileResource;
  12. class FileResourceTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testIsFresh()
  15. {
  16. $resource = new FileResource(__FILE__);
  17. $this->assertTrue($resource->isFresh(time() + 5));
  18. $this->assertFalse($resource->isFresh(0));
  19. }
  20. public function testGetContent()
  21. {
  22. $resource = new FileResource(__FILE__);
  23. $this->assertEquals(file_get_contents(__FILE__), $resource->getContent());
  24. }
  25. public function testIsFreshOnInvalidPath()
  26. {
  27. $resource = new FileResource(__FILE__.'foo');
  28. $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the file does not exist');
  29. }
  30. public function testGetContentOnInvalidPath()
  31. {
  32. $resource = new FileResource(__FILE__.'foo');
  33. $this->assertSame('', $resource->getContent(), '->getContent() returns an empty string when path is invalid');
  34. }
  35. }