Blame view
sources/3rdparty/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetReferenceTest.php
3.55 KB
|
6d9380f96
|
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
<?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\AssetReference;
class AssetReferenceTest extends \PHPUnit_Framework_TestCase
{
private $am;
private $ref;
protected function setUp()
{
$this->am = $this->getMock('Assetic\\AssetManager');
$this->ref = new AssetReference($this->am, 'foo');
}
/**
* @dataProvider getMethodAndRetVal
*/
public function testMethods($method, $returnValue)
{
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
$this->am->expects($this->once())
->method('get')
->with('foo')
->will($this->returnValue($asset));
$asset->expects($this->once())
->method($method)
->will($this->returnValue($returnValue));
$this->assertEquals($returnValue, $this->ref->$method(), '->'.$method.'() returns the asset value');
}
public function getMethodAndRetVal()
{
return array(
array('getContent', 'asdf'),
array('getSourceRoot', 'asdf'),
array('getSourcePath', 'asdf'),
array('getTargetPath', 'asdf'),
array('getLastModified', 123),
);
}
public function testLazyFilters()
{
$this->am->expects($this->never())->method('get');
$this->ref->ensureFilter($this->getMock('Assetic\\Filter\\FilterInterface'));
}
public function testFilterFlush()
{
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
$this->am->expects($this->exactly(2))
->method('get')
->with('foo')
->will($this->returnValue($asset));
$asset->expects($this->once())->method('ensureFilter');
$asset->expects($this->once())
->method('getFilters')
->will($this->returnValue(array()));
$this->ref->ensureFilter($this->getMock('Assetic\\Filter\\FilterInterface'));
$this->assertInternalType('array', $this->ref->getFilters(), '->getFilters() flushes and returns filters');
}
public function testSetContent()
{
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
$this->am->expects($this->once())
->method('get')
->with('foo')
->will($this->returnValue($asset));
$asset->expects($this->once())
->method('setContent')
->with('asdf');
$this->ref->setContent('asdf');
}
public function testLoad()
{
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
$this->am->expects($this->exactly(2))
->method('get')
->with('foo')
->will($this->returnValue($asset));
$asset->expects($this->once())
->method('load')
->with($filter);
$this->ref->load($filter);
}
public function testDump()
{
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
$this->am->expects($this->exactly(2))
->method('get')
->with('foo')
->will($this->returnValue($asset));
$asset->expects($this->once())
->method('dump')
->with($filter);
$this->ref->dump($filter);
}
}
|