|
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\Asset; |
|
|
13 |
|
|
|
14 |
use Assetic\Asset\FileAsset; |
|
|
15 |
|
|
|
16 |
class FileAssetTest extends \PHPUnit_Framework_TestCase |
|
|
17 |
{ |
|
|
18 |
public function testInterface() |
|
|
19 |
{ |
|
|
20 |
$asset = new FileAsset(__FILE__); |
|
|
21 |
$this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $asset, 'Asset implements AssetInterface'); |
|
|
22 |
} |
|
|
23 |
|
|
|
24 |
public function testLazyLoading() |
|
|
25 |
{ |
|
|
26 |
$asset = new FileAsset(__FILE__); |
|
|
27 |
$this->assertEmpty($asset->getContent(), 'The asset content is empty before load'); |
|
|
28 |
|
|
|
29 |
$asset->load(); |
|
|
30 |
$this->assertNotEmpty($asset->getContent(), 'The asset content is not empty after load'); |
|
|
31 |
} |
|
|
32 |
|
|
|
33 |
public function testGetLastModifiedType() |
|
|
34 |
{ |
|
|
35 |
$asset = new FileAsset(__FILE__); |
|
|
36 |
$this->assertInternalType('integer', $asset->getLastModified(), '->getLastModified() returns an integer'); |
|
|
37 |
} |
|
|
38 |
|
|
|
39 |
public function testGetLastModifiedValue() |
|
|
40 |
{ |
|
|
41 |
$asset = new FileAsset(__FILE__); |
|
|
42 |
$this->assertLessThan(time(), $asset->getLastModified(), '->getLastModified() returns the mtime'); |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
public function testDefaultBaseAndPath() |
|
|
46 |
{ |
|
|
47 |
$asset = new FileAsset(__FILE__); |
|
|
48 |
$this->assertEquals(__DIR__, $asset->getSourceRoot(), '->__construct() defaults base to the asset directory'); |
|
|
49 |
$this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() defaults path to the asset basename'); |
|
|
50 |
} |
|
|
51 |
|
|
|
52 |
public function testPathGuessing() |
|
|
53 |
{ |
|
|
54 |
$asset = new FileAsset(__FILE__, array(), __DIR__); |
|
|
55 |
$this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() guesses the asset path'); |
|
|
56 |
} |
|
|
57 |
|
|
|
58 |
public function testInvalidBase() |
|
|
59 |
{ |
|
|
60 |
$this->setExpectedException('InvalidArgumentException'); |
|
|
61 |
|
|
|
62 |
$asset = new FileAsset(__FILE__, array(), __DIR__.'/foo'); |
|
|
63 |
} |
|
|
64 |
} |