AssetWriterCacheWarmerTest.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of the Symfony framework.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\Bundle\AsseticBundle\Tests\CacheWarmer;
  11. use Symfony\Bundle\AsseticBundle\CacheWarmer\AssetWriterCacheWarmer;
  12. class AssetWriterCacheWarmerTest extends \PHPUnit_Framework_TestCase
  13. {
  14. protected function setUp()
  15. {
  16. if (!class_exists('Assetic\\AssetManager')) {
  17. $this->markTestSkipped('Assetic is not available.');
  18. }
  19. }
  20. public function testWarmUp()
  21. {
  22. $am = $this->getMock('Assetic\\AssetManager');
  23. $writer = $this
  24. ->getMockBuilder('Assetic\\AssetWriter')
  25. ->disableOriginalConstructor()
  26. ->getMock()
  27. ;
  28. $writer
  29. ->expects($this->once())
  30. ->method('writeManagerAssets')
  31. ->with($am)
  32. ;
  33. $container = $this
  34. ->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')
  35. ->setConstructorArgs(array())
  36. ->getMock()
  37. ;
  38. $container
  39. ->expects($this->once())
  40. ->method('get')
  41. ->with('assetic.asset_manager')
  42. ->will($this->returnValue($am))
  43. ;
  44. $warmer = new AssetWriterCacheWarmer($container, $writer);
  45. $warmer->warmUp('/path/to/cache');
  46. }
  47. }