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/Components/DependencyInjection/Resource/FileResourceTest.php

52 lines
1.6 KiB
PHP
Raw Normal View History

<?php
/*
2010-04-25 16:06:54 +01:00
* This file is part of the Symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
2010-04-07 02:07:59 +01:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2010-06-27 17:28:29 +01:00
namespace Symfony\Tests\Components\DependencyInjection\Resource;
2010-06-27 17:28:29 +01:00
use Symfony\Components\DependencyInjection\Resource\FileResource;
class FileResourceTest extends \PHPUnit_Framework_TestCase
{
protected $resource;
protected $file;
public function setUp()
{
$this->file = sys_get_temp_dir().'/tmp.xml';
touch($this->file);
$this->resource = new FileResource($this->file);
}
public function tearDown()
{
unlink($this->file);
}
2010-06-27 17:28:29 +01:00
/**
* @covers Symfony\Components\DependencyInjection\Resource\FileResource::getResource
*/
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-06-27 17:28:29 +01:00
/**
* @covers Symfony\Components\DependencyInjection\Resource\FileResource::isUptodate
*/
public function testIsUptodate()
{
$this->assertTrue($this->resource->isUptodate(time() + 10), '->isUptodate() returns true if the resource has not changed');
$this->assertFalse($this->resource->isUptodate(time() - 86400), '->isUptodate() returns false if the resource has been updated');
$resource = new FileResource('/____foo/foobar'.rand(1, 999999));
$this->assertFalse($resource->isUptodate(time()), '->isUptodate() returns false if the resource does not exist');
}
}