AssetManagerTest.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\AssetManager;
  12. class AssetManagerTest extends \PHPUnit_Framework_TestCase
  13. {
  14. private $am;
  15. protected function setUp()
  16. {
  17. $this->am = new AssetManager();
  18. }
  19. public function testGetAsset()
  20. {
  21. $asset = $this->getMock('Assetic\\Asset\\AssetInterface');
  22. $this->am->set('foo', $asset);
  23. $this->assertSame($asset, $this->am->get('foo'), '->get() returns an asset');
  24. }
  25. public function testGetInvalidAsset()
  26. {
  27. $this->setExpectedException('InvalidArgumentException');
  28. $this->am->get('foo');
  29. }
  30. public function testHas()
  31. {
  32. $asset = $this->getMock('Assetic\\Asset\\AssetInterface');
  33. $this->am->set('foo', $asset);
  34. $this->assertTrue($this->am->has('foo'), '->has() returns true if the asset is set');
  35. $this->assertFalse($this->am->has('bar'), '->has() returns false if the asset is not set');
  36. }
  37. public function testInvalidName()
  38. {
  39. $this->setExpectedException('InvalidArgumentException');
  40. $this->am->set('@foo', $this->getMock('Assetic\\Asset\\AssetInterface'));
  41. }
  42. }