PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / kriswallsmith / assetic / tests / Assetic / Test / Asset / FileAssetTest.php

FileAssetTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/FileAssetTest.php

75 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Assetic package, an OpenSky project.
5 *
6 * (c) 2010-2014 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 testGetLastModifiedTypeFileNotFound()
40 {
41 $asset = new FileAsset(__DIR__."/foo/bar/baz.css");
42
43 $this->setExpectedException("RuntimeException", "The source file");
44 $asset->getLastModified();
45 }
46
47 public function testGetLastModifiedValue()
48 {
49 $asset = new FileAsset(__FILE__);
50 $this->assertLessThan(time(), $asset->getLastModified(), '->getLastModified() returns the mtime');
51 }
52
53 public function testDefaultBaseAndPath()
54 {
55 $asset = new FileAsset(__FILE__);
56 $this->assertEquals(__DIR__, $asset->getSourceRoot(), '->__construct() defaults base to the asset directory');
57 $this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() defaults path to the asset basename');
58 $this->assertEquals(__DIR__, $asset->getSourceDirectory(), '->__construct() derives the asset directory');
59 }
60
61 public function testPathGuessing()
62 {
63 $asset = new FileAsset(__FILE__, array(), __DIR__);
64 $this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() guesses the asset path');
65 $this->assertEquals(__DIR__, $asset->getSourceDirectory(), '->__construct() derives the asset directory');
66 }
67
68 public function testInvalidBase()
69 {
70 $this->setExpectedException('InvalidArgumentException');
71
72 $asset = new FileAsset(__FILE__, array(), __DIR__.'/foo');
73 }
74 }
75