FileAssetTest.php
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/*
* This file is part of the Assetic package, an OpenSky project.
*
* (c) 2010-2014 OpenSky Project Inc
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Assetic\Test\Asset;
use Assetic\Asset\FileAsset;
class FileAssetTest extends \PHPUnit_Framework_TestCase
{
public function testInterface()
{
$asset = new FileAsset(__FILE__);
$this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $asset, 'Asset implements AssetInterface');
}
public function testLazyLoading()
{
$asset = new FileAsset(__FILE__);
$this->assertEmpty($asset->getContent(), 'The asset content is empty before load');
$asset->load();
$this->assertNotEmpty($asset->getContent(), 'The asset content is not empty after load');
}
public function testGetLastModifiedType()
{
$asset = new FileAsset(__FILE__);
$this->assertInternalType('integer', $asset->getLastModified(), '->getLastModified() returns an integer');
}
public function testGetLastModifiedTypeFileNotFound()
{
$asset = new FileAsset(__DIR__ . "/foo/bar/baz.css");
$this->setExpectedException("RuntimeException", "The source file");
$asset->getLastModified();
}
public function testGetLastModifiedValue()
{
$asset = new FileAsset(__FILE__);
$this->assertLessThan(time(), $asset->getLastModified(), '->getLastModified() returns the mtime');
}
public function testDefaultBaseAndPath()
{
$asset = new FileAsset(__FILE__);
$this->assertEquals(__DIR__, $asset->getSourceRoot(), '->__construct() defaults base to the asset directory');
$this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() defaults path to the asset basename');
$this->assertEquals(__DIR__, $asset->getSourceDirectory(), '->__construct() derives the asset directory');
}
public function testPathGuessing()
{
$asset = new FileAsset(__FILE__, array(), __DIR__);
$this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() guesses the asset path');
$this->assertEquals(__DIR__, $asset->getSourceDirectory(), '->__construct() derives the asset directory');
}
public function testInvalidBase()
{
$this->setExpectedException('InvalidArgumentException');
$asset = new FileAsset(__FILE__, array(), __DIR__.'/foo');
}
}