StringAssetTest.php 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /*
  3. * This file is part of the Assetic package, an OpenSky project.
  4. *
  5. * (c) 2010-2011 OpenSky Project Inc
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Assetic\Test\Asset;
  11. use Assetic\Asset\StringAsset;
  12. class StringAssetTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testInterface()
  15. {
  16. $asset = new StringAsset('');
  17. $this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $asset, 'Asset implements AssetInterface');
  18. }
  19. public function testLoadAppliesFilters()
  20. {
  21. $filter = $this->getMock('Assetic\\Filter\\FilterInterface');
  22. $filter->expects($this->once())->method('filterLoad');
  23. $asset = new StringAsset('foo', array($filter));
  24. $asset->load();
  25. }
  26. public function testAutomaticLoad()
  27. {
  28. $filter = $this->getMock('Assetic\\Filter\\FilterInterface');
  29. $filter->expects($this->once())->method('filterLoad');
  30. $asset = new StringAsset('foo', array($filter));
  31. $asset->dump();
  32. }
  33. public function testGetFilters()
  34. {
  35. $asset = new StringAsset('');
  36. $this->assertInternalType('array', $asset->getFilters(), '->getFilters() returns an array');
  37. }
  38. public function testLoadAppliesAdditionalFilter()
  39. {
  40. $asset = new StringAsset('');
  41. $asset->load();
  42. $filter = $this->getMock('Assetic\\Filter\\FilterInterface');
  43. $filter->expects($this->once())
  44. ->method('filterLoad')
  45. ->with($asset);
  46. $asset->load($filter);
  47. }
  48. public function testDumpAppliesAdditionalFilter()
  49. {
  50. $asset = new StringAsset('');
  51. $filter = $this->getMock('Assetic\\Filter\\FilterInterface');
  52. $filter->expects($this->once())
  53. ->method('filterDump')
  54. ->with($asset);
  55. $asset->dump($filter);
  56. }
  57. public function testLastModified()
  58. {
  59. $asset = new StringAsset('');
  60. $asset->setLastModified(123);
  61. $this->assertEquals(123, $asset->getLastModified(), '->getLastModified() return the set last modified value');
  62. }
  63. }