FunctionalTest.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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;
  11. use Symfony\Component\DomCrawler\Crawler;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpKernel\Util\Filesystem;
  14. /**
  15. * @group functional
  16. */
  17. class FunctionalTest extends \PHPUnit_Framework_TestCase
  18. {
  19. protected $cacheDir;
  20. protected function setUp()
  21. {
  22. if (!class_exists('Assetic\\AssetManager')) {
  23. $this->markTestSkipped('Assetic is not available.');
  24. }
  25. $this->cacheDir = __DIR__.'/Resources/cache';
  26. if (file_exists($this->cacheDir)) {
  27. $filesystem = new Filesystem();
  28. $filesystem->remove($this->cacheDir);
  29. }
  30. mkdir($this->cacheDir, 0777, true);
  31. }
  32. protected function tearDown()
  33. {
  34. $filesystem = new Filesystem();
  35. $filesystem->remove($this->cacheDir);
  36. }
  37. public function testTwigRenderDebug()
  38. {
  39. $kernel = new TestKernel('test', true);
  40. $kernel->boot();
  41. $container = $kernel->getContainer();
  42. $container->enterScope('request');
  43. $container->set('request', new Request());
  44. $content = $container->get('templating')->render('::layout.html.twig');
  45. $crawler = new Crawler($content);
  46. $this->assertEquals(3, count($crawler->filter('link[href$=".css"]')));
  47. $this->assertEquals(2, count($crawler->filter('script[src$=".js"]')));
  48. }
  49. public function testPhpRenderDebug()
  50. {
  51. $kernel = new TestKernel('test', true);
  52. $kernel->boot();
  53. $container = $kernel->getContainer();
  54. $container->enterScope('request');
  55. $container->set('request', new Request());
  56. $content = $container->get('templating')->render('::layout.html.php');
  57. $crawler = new Crawler($content);
  58. $this->assertEquals(3, count($crawler->filter('link[href$=".css"]')));
  59. $this->assertEquals(2, count($crawler->filter('script[src$=".js"]')));
  60. }
  61. }