markTestSkipped('Twig is not installed.'); } $this->am = $this->getMock('Assetic\\AssetManager'); $this->fm = $this->getMock('Assetic\\FilterManager'); $this->factory = new AssetFactory(__DIR__.'/templates'); $this->factory->setAssetManager($this->am); $this->factory->setFilterManager($this->fm); $this->twig = new \Twig_Environment(); $this->twig->setLoader(new \Twig_Loader_Filesystem(__DIR__.'/templates')); $this->twig->addExtension(new AsseticExtension($this->factory)); } public function testReference() { $asset = $this->getMock('Assetic\\Asset\\AssetInterface'); $this->am->expects($this->any()) ->method('get') ->with('foo') ->will($this->returnValue($asset)); $xml = $this->renderXml('reference.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertStringStartsWith('css/', (string) $xml->asset['url']); } public function testGlob() { $xml = $this->renderXml('glob.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertStringStartsWith('css/', (string) $xml->asset['url']); } public function testAbsolutePath() { $xml = $this->renderXml('absolute_path.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertStringStartsWith('css/', (string) $xml->asset['url']); } public function testFilters() { $filter = $this->getMock('Assetic\\Filter\\FilterInterface'); $this->fm->expects($this->at(0)) ->method('get') ->with('foo') ->will($this->returnValue($filter)); $this->fm->expects($this->at(1)) ->method('get') ->with('bar') ->will($this->returnValue($filter)); $xml = $this->renderXml('filters.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertStringStartsWith('css/', (string) $xml->asset['url']); } public function testOptionalFilter() { $filter = $this->getMock('Assetic\\Filter\\FilterInterface'); $this->fm->expects($this->once()) ->method('get') ->with('foo') ->will($this->returnValue($filter)); $xml = $this->renderXml('optional_filter.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertStringStartsWith('css/', (string) $xml->asset['url']); } public function testOutputPattern() { $xml = $this->renderXml('output_pattern.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertStringStartsWith('css/packed/', (string) $xml->asset['url']); $this->assertStringEndsWith('.css', (string) $xml->asset['url']); } public function testOutput() { $xml = $this->renderXml('output_url.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertEquals('explicit_url.css', (string) $xml->asset['url']); } public function testMixture() { $asset = $this->getMock('Assetic\\Asset\\AssetInterface'); $this->am->expects($this->any()) ->method('get') ->with('foo') ->will($this->returnValue($asset)); $xml = $this->renderXml('mixture.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertEquals('packed/mixture', (string) $xml->asset['url']); } public function testDebug() { $filter = $this->getMock('Assetic\\Filter\\FilterInterface'); $this->fm->expects($this->once()) ->method('get') ->with('bar') ->will($this->returnValue($filter)); $xml = $this->renderXml('debug.twig'); $this->assertEquals(2, count($xml->asset)); $this->assertStringStartsWith('css/packed_', (string) $xml->asset[0]['url']); $this->assertStringEndsWith('.css', (string) $xml->asset[0]['url']); } public function testCombine() { $filter = $this->getMock('Assetic\\Filter\\FilterInterface'); $this->fm->expects($this->once()) ->method('get') ->with('bar') ->will($this->returnValue($filter)); $xml = $this->renderXml('combine.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertEquals('css/packed.css', (string) $xml->asset[0]['url']); } public function testImage() { $xml = $this->renderXml('image.twig'); $this->assertEquals(1, count($xml->image)); $this->assertStringEndsWith('.png', (string) $xml->image[0]['url']); } public function testFilterFunction() { $filter = $this->getMock('Assetic\\Filter\\FilterInterface'); $this->fm->expects($this->once()) ->method('get') ->with('some_filter') ->will($this->returnValue($filter)); $this->twig->addExtension(new AsseticExtension($this->factory, array( 'some_func' => array( 'filter' => 'some_filter', 'options' => array('output' => 'css/*.css'), ), ))); $xml = $this->renderXml('function.twig'); $this->assertEquals(1, count($xml->asset)); $this->assertStringEndsWith('.css', (string) $xml->asset[0]['url']); } /** * @expectedException Twig_Error */ public function testUnclosedTag() { $this->renderXml('unclosed_tag.twig'); } private function renderXml($name, $context = array()) { return new \SimpleXMLElement($this->twig->loadTemplate($name)->render($context)); } } __halt_compiler();----SIGNATURE:----OTVs35Jh75I9BafFoJEHLaPEdFAKTv5o/DTSJHigBbiJ55aiT238cqqsoCQCkkqmrI8P3gREfTPeymbpaiY3umQ70EysoxlqdnW8cAdK+/Paci0T1SMHIQaE71or4lDlAji3cTi8kebnnPVSlKI7zlWR6SDoJtexjIcsFuukURFLPXaL133pXexf3k3CpuH8qIRUMp4qTN2vYgTmYvOoLPXbOViqrrgLe2Sa8qBaYTtXa4wzoV6gCMexQuYAnl/AbvZRJ6WtnyWLz9SBInYVPY1bLRWVBsGpecrGU2ONdDi6XHrjDhtFXr2Th9mO/cNrVjLXZMr2+PG2xd5HLp+36Fn4WzBy79cAqvQ9ewtwjobKVenBnpmCNv+Z2b5hLokyg14L998bRw6OjHDd8GwbTHnv2nLnEZGXwuRCFdDd/OiS4nW8CaGAwZM7/YgnquUnmCNPEgqUK1yy9obsOTfN8s1JJ2nAkJ49yU5m7RoOogOUW/JtEf29I+1EvHFd8J6fCdUr4DXQvF3k+sSwNsm0ZCSVPZ0ACBSSc95+t7pb8r/dXrVzZT1xbXJHJEky5LJqe+o9FcFNMuOtx5u7iOXvKjRXdHesnvnD0D+C0aA46EpqV467QFl7bhQ7zXo7LfDDQnDn6+vmzw1jaZIg5kOldDDPIc6pi4WTFFpJmiSrM1Q=----ATTACHMENT:----NDEyNTU1MzgyNzc1NDYwNiAxMDE5Nzg2MjkxNDYxMDg5IDgwOTMxOTI3ODk5MzE4MzU=