|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony framework. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * This source file is subject to the MIT license that is bundled |
|
9 * with this source code in the file LICENSE. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bundle\AsseticBundle\Tests; |
|
13 |
|
14 use Symfony\Component\DomCrawler\Crawler; |
|
15 use Symfony\Component\HttpFoundation\Request; |
|
16 use Symfony\Component\HttpKernel\Util\Filesystem; |
|
17 |
|
18 /** |
|
19 * @group functional |
|
20 */ |
|
21 class FunctionalTest extends \PHPUnit_Framework_TestCase |
|
22 { |
|
23 protected $cacheDir; |
|
24 |
|
25 protected function setUp() |
|
26 { |
|
27 if (!class_exists('Assetic\\AssetManager')) { |
|
28 $this->markTestSkipped('Assetic is not available.'); |
|
29 } |
|
30 |
|
31 $this->cacheDir = __DIR__.'/Resources/cache'; |
|
32 if (file_exists($this->cacheDir)) { |
|
33 $filesystem = new Filesystem(); |
|
34 $filesystem->remove($this->cacheDir); |
|
35 } |
|
36 |
|
37 mkdir($this->cacheDir, 0777, true); |
|
38 } |
|
39 |
|
40 protected function tearDown() |
|
41 { |
|
42 $filesystem = new Filesystem(); |
|
43 $filesystem->remove($this->cacheDir); |
|
44 } |
|
45 |
|
46 public function testTwigRenderDebug() |
|
47 { |
|
48 $kernel = new TestKernel('test', true); |
|
49 $kernel->boot(); |
|
50 $container = $kernel->getContainer(); |
|
51 $container->enterScope('request'); |
|
52 $container->set('request', new Request()); |
|
53 |
|
54 $content = $container->get('templating')->render('::layout.html.twig'); |
|
55 $crawler = new Crawler($content); |
|
56 |
|
57 $this->assertEquals(3, count($crawler->filter('link[href$=".css"]'))); |
|
58 $this->assertEquals(2, count($crawler->filter('script[src$=".js"]'))); |
|
59 } |
|
60 |
|
61 public function testPhpRenderDebug() |
|
62 { |
|
63 $kernel = new TestKernel('test', true); |
|
64 $kernel->boot(); |
|
65 $container = $kernel->getContainer(); |
|
66 $container->enterScope('request'); |
|
67 $container->set('request', new Request()); |
|
68 |
|
69 $content = $container->get('templating')->render('::layout.html.php'); |
|
70 $crawler = new Crawler($content); |
|
71 |
|
72 $this->assertEquals(3, count($crawler->filter('link[href$=".css"]'))); |
|
73 $this->assertEquals(2, count($crawler->filter('script[src$=".js"]'))); |
|
74 } |
|
75 } |