HttpAssetTest.php
1.75 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
<?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\HttpAsset;
class HttpAssetTest extends \PHPUnit_Framework_TestCase
{
const JQUERY = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
/**
* @group http
*/
public function testGetLastModified()
{
$asset = new HttpAsset(self::JQUERY);
$this->assertInternalType('integer', $asset->getLastModified(), '->getLastModified() returns an integer');
}
/**
* @group http
*/
public function testProtocolRelativeUrl()
{
$asset = new HttpAsset(substr(self::JQUERY, 5));
$asset->load();
$this->assertNotEmpty($asset->getContent());
}
public function testMalformedUrl()
{
$this->setExpectedException('InvalidArgumentException');
new HttpAsset(__FILE__);
}
public function testInvalidUrl()
{
$this->setExpectedException('RuntimeException');
$asset = new HttpAsset('http://invalid.com/foobar');
$asset->load();
}
public function testSourceMetadata()
{
$asset = new HttpAsset(self::JQUERY);
$this->assertEquals('http://ajax.googleapis.com', $asset->getSourceRoot(), '->__construct() set the source root');
$this->assertEquals('ajax/libs/jquery/1.6.1/jquery.min.js', $asset->getSourcePath(), '->__construct() set the source path');
$this->assertEquals('http://ajax.googleapis.com/ajax/libs/jquery/1.6.1', $asset->getSourceDirectory(), '->__construct() sets the source directory');
}
}