|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony framework. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* This source file is subject to the MIT license that is bundled |
|
|
9 |
* with this source code in the file LICENSE. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Symfony\Bundle\AsseticBundle\Tests\Templating; |
|
|
13 |
|
|
|
14 |
use Assetic\Asset\AssetCollection; |
|
|
15 |
use Assetic\Asset\AssetInterface; |
|
|
16 |
use Assetic\Asset\StringAsset; |
|
|
17 |
use Assetic\Factory\AssetFactory; |
|
|
18 |
use Symfony\Bundle\AsseticBundle\Templating\AsseticHelper; |
|
|
19 |
|
|
|
20 |
class AsseticHelperTest extends \PHPUnit_Framework_TestCase |
|
|
21 |
{ |
|
|
22 |
protected function setUp() |
|
|
23 |
{ |
|
|
24 |
if (!class_exists('Assetic\\AssetManager')) { |
|
|
25 |
$this->markTestSkipped('Assetic is not available.'); |
|
|
26 |
} |
|
|
27 |
} |
|
|
28 |
|
|
|
29 |
/** |
|
|
30 |
* @dataProvider getDebugAndCount |
|
|
31 |
*/ |
|
|
32 |
public function testUrls($debug, $count, $message) |
|
|
33 |
{ |
|
|
34 |
$helper = new AsseticHelperForTest(new AssetFactory('/foo', $debug), $debug); |
|
|
35 |
$urls = $helper->javascripts(array('js/jquery.js', 'js/jquery.plugin.js')); |
|
|
36 |
|
|
|
37 |
$this->assertInstanceOf('Traversable', $urls, '->javascripts() returns an array'); |
|
|
38 |
$this->assertEquals($count, count($urls), $message); |
|
|
39 |
} |
|
|
40 |
|
|
|
41 |
public function getDebugAndCount() |
|
|
42 |
{ |
|
|
43 |
return array( |
|
|
44 |
array(false, 1, '->javascripts() returns one url when not in debug mode'), |
|
|
45 |
array(true, 2, '->javascripts() returns many urls when in debug mode'), |
|
|
46 |
); |
|
|
47 |
} |
|
|
48 |
} |
|
|
49 |
|
|
|
50 |
class AsseticHelperForTest extends AsseticHelper |
|
|
51 |
{ |
|
|
52 |
protected function getAssetUrl(AssetInterface $asset, $options = array()) |
|
|
53 |
{ |
|
|
54 |
return $asset->getTargetPath(); |
|
|
55 |
} |
|
|
56 |
} |