PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/vendor/assetic/tests/Assetic/Test/AssetWriterTest.php

https://bitbucket.org/ErunamoJAZZ/untdg
PHP | 55 lines | 38 code | 9 blank | 8 comment | 0 complexity | 40247e6c283ee0dc8db09c46b1ae879e MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, LGPL-3.0, BSD-3-Clause, BSD-2-Clause
  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;
  11. use Assetic\AssetWriter;
  12. class AssetWriterTest extends \PHPUnit_Framework_TestCase
  13. {
  14. protected function setUp()
  15. {
  16. $this->dir = sys_get_temp_dir().'/assetic_tests_'.rand(11111, 99999);
  17. mkdir($this->dir);
  18. $this->writer = new AssetWriter($this->dir);
  19. }
  20. protected function tearDown()
  21. {
  22. array_map('unlink', glob($this->dir.'/*'));
  23. rmdir($this->dir);
  24. }
  25. public function testWriteManagerAssets()
  26. {
  27. $asset = $this->getMock('Assetic\\Asset\\AssetInterface');
  28. $am = $this->getMock('Assetic\\AssetManager');
  29. $am->expects($this->once())
  30. ->method('getNames')
  31. ->will($this->returnValue(array('foo')));
  32. $am->expects($this->once())
  33. ->method('get')
  34. ->with('foo')
  35. ->will($this->returnValue($asset));
  36. $asset->expects($this->once())
  37. ->method('getTargetPath')
  38. ->will($this->returnValue('target_url'));
  39. $asset->expects($this->once())
  40. ->method('dump')
  41. ->will($this->returnValue('content'));
  42. $this->writer->writeManagerAssets($am);
  43. $this->assertFileExists($this->dir.'/target_url');
  44. $this->assertEquals('content', file_get_contents($this->dir.'/target_url'));
  45. }
  46. }