StylesheetsHelperTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. require_once __DIR__.'/../../../bootstrap.php';
  12. use Symfony\Components\Templating\Helper\AssetsHelper;
  13. use Symfony\Components\Templating\Helper\StylesheetsHelper;
  14. use Symfony\Components\Templating\Loader\FilesystemLoader;
  15. class StylesheetsHelperTest extends \PHPUnit_Framework_TestCase
  16. {
  17. public function testAdd()
  18. {
  19. $assetHelper = new AssetsHelper();
  20. $helper = new StylesheetsHelper($assetHelper);
  21. $helper->add('foo');
  22. $this->assertEquals($helper->get(), array('/foo' => array()), '->add() adds a stylesheet');
  23. $helper->add('/foo');
  24. $this->assertEquals($helper->get(), array('/foo' => array()), '->add() does not add the same stylesheet twice');
  25. $helper = new StylesheetsHelper($assetHelper);
  26. $assetHelper->setBaseURLs('http://assets.example.com/');
  27. $helper->add('foo');
  28. $this->assertEquals($helper->get(), array('http://assets.example.com/foo' => array()), '->add() converts the stylesheet to a public path');
  29. }
  30. public function testMagicToString()
  31. {
  32. $assetHelper = new AssetsHelper();
  33. $assetHelper->setBaseURLs('');
  34. $helper = new StylesheetsHelper($assetHelper);
  35. $helper->add('foo', array('media' => 'ba>'));
  36. $this->assertEquals($helper->__toString(), '<link href="/foo" rel="stylesheet" type="text/css" media="ba&gt;" />'."\n", '->__toString() converts the stylesheet configuration to HTML');
  37. }
  38. }