|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Assetic package, an OpenSky project. |
|
|
5 |
* |
|
|
6 |
* (c) 2010-2011 OpenSky Project Inc |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Assetic\Test\Factory\Resource; |
|
|
13 |
|
|
|
14 |
use Assetic\Factory\Resource\FileResource; |
|
|
15 |
|
|
|
16 |
class FileResourceTest extends \PHPUnit_Framework_TestCase |
|
|
17 |
{ |
|
|
18 |
public function testIsFresh() |
|
|
19 |
{ |
|
|
20 |
$resource = new FileResource(__FILE__); |
|
|
21 |
$this->assertTrue($resource->isFresh(time() + 5)); |
|
|
22 |
$this->assertFalse($resource->isFresh(0)); |
|
|
23 |
} |
|
|
24 |
|
|
|
25 |
public function testGetContent() |
|
|
26 |
{ |
|
|
27 |
$resource = new FileResource(__FILE__); |
|
|
28 |
$this->assertEquals(file_get_contents(__FILE__), $resource->getContent()); |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
public function testIsFreshOnInvalidPath() |
|
|
32 |
{ |
|
|
33 |
$resource = new FileResource(__FILE__.'foo'); |
|
|
34 |
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the file does not exist'); |
|
|
35 |
} |
|
|
36 |
|
|
|
37 |
public function testGetContentOnInvalidPath() |
|
|
38 |
{ |
|
|
39 |
$resource = new FileResource(__FILE__.'foo'); |
|
|
40 |
$this->assertSame('', $resource->getContent(), '->getContent() returns an empty string when path is invalid'); |
|
|
41 |
} |
|
|
42 |
} |