|
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; |
|
|
13 |
|
|
|
14 |
use Assetic\AssetWriter; |
|
|
15 |
|
|
|
16 |
class AssetWriterTest extends \PHPUnit_Framework_TestCase |
|
|
17 |
{ |
|
|
18 |
protected function setUp() |
|
|
19 |
{ |
|
|
20 |
$this->dir = sys_get_temp_dir().'/assetic_tests_'.rand(11111, 99999); |
|
|
21 |
mkdir($this->dir); |
|
|
22 |
$this->writer = new AssetWriter($this->dir); |
|
|
23 |
} |
|
|
24 |
|
|
|
25 |
protected function tearDown() |
|
|
26 |
{ |
|
|
27 |
array_map('unlink', glob($this->dir.'/*')); |
|
|
28 |
rmdir($this->dir); |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
public function testWriteManagerAssets() |
|
|
32 |
{ |
|
|
33 |
$asset = $this->getMock('Assetic\\Asset\\AssetInterface'); |
|
|
34 |
$am = $this->getMock('Assetic\\AssetManager'); |
|
|
35 |
|
|
|
36 |
$am->expects($this->once()) |
|
|
37 |
->method('getNames') |
|
|
38 |
->will($this->returnValue(array('foo'))); |
|
|
39 |
$am->expects($this->once()) |
|
|
40 |
->method('get') |
|
|
41 |
->with('foo') |
|
|
42 |
->will($this->returnValue($asset)); |
|
|
43 |
$asset->expects($this->once()) |
|
|
44 |
->method('getTargetPath') |
|
|
45 |
->will($this->returnValue('target_url')); |
|
|
46 |
$asset->expects($this->once()) |
|
|
47 |
->method('dump') |
|
|
48 |
->will($this->returnValue('content')); |
|
|
49 |
|
|
|
50 |
$this->writer->writeManagerAssets($am); |
|
|
51 |
|
|
|
52 |
$this->assertFileExists($this->dir.'/target_url'); |
|
|
53 |
$this->assertEquals('content', file_get_contents($this->dir.'/target_url')); |
|
|
54 |
} |
|
|
55 |
} |