FileResourceTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\Translation\Resource;
  11. use Symfony\Component\Translation\Resource\FileResource;
  12. class FileResourceTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @expectedException InvalidArgumentException
  16. */
  17. public function testConstructor()
  18. {
  19. $resource = new FileResource(__DIR__.'/../fixtures/foobar');
  20. }
  21. public function testMagicToString()
  22. {
  23. $resource = new FileResource(__DIR__.'/../fixtures/resources.php');
  24. $this->assertEquals(realpath(__DIR__.'/../fixtures/resources.php'), (string) $resource);
  25. }
  26. public function testGetResource()
  27. {
  28. $resource = new FileResource(__DIR__.'/../fixtures/resources.php');
  29. $this->assertEquals(realpath(__DIR__.'/../fixtures/resources.php'), $resource->getResource());
  30. }
  31. public function testIsUptodate()
  32. {
  33. $r = __DIR__.'/../fixtures/resources.php';
  34. $resource = new FileResource($r);
  35. $this->assertFalse($resource->isUptodate(filemtime($r) - 100));
  36. $this->assertTrue($resource->isUptodate(filemtime($r) + 100));
  37. }
  38. }