StylesheetsHelperTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  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 Symfony\Tests\Components\Templating\Helper;
  11. use Symfony\Components\Templating\Helper\AssetsHelper;
  12. use Symfony\Components\Templating\Helper\StylesheetsHelper;
  13. use Symfony\Components\Templating\Loader\FilesystemLoader;
  14. class StylesheetsHelperTest extends \PHPUnit_Framework_TestCase
  15. {
  16. public function testAdd()
  17. {
  18. $assetHelper = new AssetsHelper();
  19. $helper = new StylesheetsHelper($assetHelper);
  20. $helper->add('foo');
  21. $this->assertEquals(array('/foo' => array()), $helper->get(), '->add() adds a stylesheet');
  22. $helper->add('/foo');
  23. $this->assertEquals(array('/foo' => array()), $helper->get(), '->add() does not add the same stylesheet twice');
  24. $helper = new StylesheetsHelper($assetHelper);
  25. $assetHelper->setBaseURLs('http://assets.example.com/');
  26. $helper->add('foo');
  27. $this->assertEquals(array('http://assets.example.com/foo' => array()), $helper->get(), '->add() converts the stylesheet to a public path');
  28. }
  29. public function testMagicToString()
  30. {
  31. $assetHelper = new AssetsHelper();
  32. $assetHelper->setBaseURLs('');
  33. $helper = new StylesheetsHelper($assetHelper);
  34. $helper->add('foo', array('media' => 'ba>'));
  35. $this->assertEquals('<link href="/foo" rel="stylesheet" type="text/css" media="ba&gt;" />'."\n", $helper->__toString(), '->__toString() converts the stylesheet configuration to HTML');
  36. }
  37. }