Exemplo n.º 1
0
 /**
  * @test
  * @dataProvider stylesheetCachingParametersProvider
  */
 public function dontCacheStylesheetConstraintByDefault($numberOfCacheMethodInvoking, $useCache)
 {
     $facade = new Facade(new LoaderImpl(), $this->createDocumentStub(), $this->documentParser, $this->stylesheetParser);
     $cache = $this->getMock('PHPPdf\\Cache\\NullCache', array('test', 'save', 'load'));
     $cache->expects($this->exactly($numberOfCacheMethodInvoking))->method('test')->will($this->returnValue(false));
     $cache->expects($this->exactly(0))->method('load');
     $cache->expects($this->exactly($numberOfCacheMethodInvoking))->method('save');
     $this->documentParser->expects($this->once())->method('parse')->will($this->returnValue(new \PHPPdf\Core\Node\PageCollection()));
     $this->stylesheetParser->expects($this->once())->method('parse')->will($this->returnValue(new \PHPPdf\Core\Parser\CachingStylesheetConstraint()));
     $facade->setCache($cache);
     $facade->setUseCacheForStylesheetConstraint($useCache);
     $facade->render('<pdf></pdf>', '<stylesheet></stylesheet>');
 }
Exemplo n.º 2
0
    private function renderDocumentWithFooter($footer, $useTemplate)
    {
        $template = $useTemplate ? 'document-template="' . __DIR__ . '/../../Resources/test.pdf"' : '';
        return $this->facade->render('<pdf>
    <dynamic-page encoding="UTF-8" ' . $template . '>
                <placeholders>
                    <header>
                        <div height="50px" width="100%" color="green">
                            Some header
                        </div>
                    </header>
                    <footer>
                        <div height="50px" width="100%" color="green">
                             ' . $footer . '
                        </div>
                    </footer>
                </placeholders>

                <p>Lorum ipsum</p>

            </dynamic-page>
        </pdf>', '<stylesheet></stylesheet>');
    }