This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Config/Resource/FileResourceTest.php
2011-03-06 12:40:06 +01:00

53 lines
1.5 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Tests\Component\Config\Resource;
use Symfony\Component\Config\Resource\FileResource;
class FileResourceTest extends \PHPUnit_Framework_TestCase
{
protected $resource;
protected $file;
protected function setUp()
{
$this->file = sys_get_temp_dir().'/tmp.xml';
touch($this->file);
$this->resource = new FileResource($this->file);
}
protected function tearDown()
{
unlink($this->file);
}
/**
* @covers Symfony\Component\Config\Resource\FileResource::getResource
*/
public function testGetResource()
{
$this->assertEquals(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource');
}
/**
* @covers Symfony\Component\Config\Resource\FileResource::isFresh
*/
public function testIsFresh()
{
$this->assertTrue($this->resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
$this->assertFalse($this->resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
$resource = new FileResource('/____foo/foobar'.rand(1, 999999));
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
}
}