2010-03-18 07:48:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2010-04-25 16:06:54 +01:00
|
|
|
* This file is part of the Symfony package.
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-04-07 02:07:59 +01:00
|
|
|
*
|
2010-03-18 07:48:03 +00:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2011-02-10 15:15:51 +00:00
|
|
|
namespace Symfony\Tests\Component\Config\Resource;
|
2010-03-18 07:48:03 +00:00
|
|
|
|
2011-02-10 15:15:51 +00:00
|
|
|
use Symfony\Component\Config\Resource\FileResource;
|
2010-03-18 07:48:03 +00:00
|
|
|
|
|
|
|
class FileResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2010-05-06 12:25:53 +01:00
|
|
|
protected $resource;
|
|
|
|
protected $file;
|
|
|
|
|
2010-12-06 14:45:37 +00:00
|
|
|
protected function setUp()
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
|
|
|
$this->file = sys_get_temp_dir().'/tmp.xml';
|
|
|
|
touch($this->file);
|
|
|
|
$this->resource = new FileResource($this->file);
|
|
|
|
}
|
|
|
|
|
2010-12-06 14:45:37 +00:00
|
|
|
protected function tearDown()
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
|
|
|
unlink($this->file);
|
|
|
|
}
|
|
|
|
|
2010-06-27 17:28:29 +01:00
|
|
|
/**
|
2011-02-10 15:15:51 +00:00
|
|
|
* @covers Symfony\Component\Config\Resource\FileResource::getResource
|
2010-06-27 17:28:29 +01:00
|
|
|
*/
|
2010-05-06 12:25:53 +01:00
|
|
|
public function testGetResource()
|
|
|
|
{
|
2010-06-28 08:14:33 +01:00
|
|
|
$this->assertEquals(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource');
|
2010-05-06 12:25:53 +01:00
|
|
|
}
|
|
|
|
|
2010-06-27 17:28:29 +01:00
|
|
|
/**
|
2011-02-10 15:15:51 +00:00
|
|
|
* @covers Symfony\Component\Config\Resource\FileResource::isFresh
|
2010-06-27 17:28:29 +01:00
|
|
|
*/
|
2011-02-10 15:15:51 +00:00
|
|
|
public function testIsFresh()
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
2011-02-10 15:15:51 +00:00
|
|
|
$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');
|
2010-05-06 12:25:53 +01:00
|
|
|
|
|
|
|
$resource = new FileResource('/____foo/foobar'.rand(1, 999999));
|
2011-02-10 15:15:51 +00:00
|
|
|
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
|
2010-05-06 12:25:53 +01:00
|
|
|
}
|
2010-03-18 07:48:03 +00:00
|
|
|
}
|