engine() публичный Метод

Load PdfEngine
public engine ( string $name = null ) : CakePdf\Pdf\Engine\AbstractPdfEngine
$name string Classname of pdf engine without `Engine` suffix. For example `CakePdf.DomPdf`
Результат CakePdf\Pdf\Engine\AbstractPdfEngine
Пример #1
0
 /**
  * Tests that the Dompdf instance is being processed as expected.
  */
 public function testDompdfControlFlow()
 {
     $engineClass = $this->getMockClass('\\CakePdf\\Pdf\\Engine\\DomPdfEngine', ['_createInstance']);
     $Pdf = new CakePdf(['engine' => '\\' . $engineClass]);
     $Pdf->engine()->expects($this->once())->method('_createInstance')->will($this->returnCallback(function ($options) {
         $Dompdf = $this->getMock('\\Dompdf\\Dompdf', ['setPaper', 'loadHtml', 'render', 'output'], [$options]);
         $Dompdf->expects($this->at(0))->method('setPaper')->with('A4', 'portrait');
         $Dompdf->expects($this->at(1))->method('loadHtml')->with(null);
         $Dompdf->expects($this->at(2))->method('render');
         $Dompdf->expects($this->at(3))->method('output');
         return $Dompdf;
     }));
     $Pdf->engine()->output();
 }
Пример #2
0
 /**
  * Tests that the engine generates the right command
  */
 public function testGetCommand()
 {
     $class = new \ReflectionClass('CakePdf\\Pdf\\Engine\\WkHtmlToPdfEngine');
     $method = $class->getMethod('_getCommand');
     $method->setAccessible(true);
     $Pdf = new CakePdf(['engine' => ['className' => 'CakePdf.WkHtmlToPdf', 'options' => ['quiet' => false, 'encoding' => 'ISO-8859-1']], 'title' => 'CakePdf rules']);
     $result = $method->invokeArgs($Pdf->engine(), []);
     $expected = "/usr/bin/wkhtmltopdf --print-media-type --orientation 'portrait' --page-size 'A4' --encoding 'ISO-8859-1' --title 'CakePdf rules' - -";
     $this->assertEquals($expected, $result);
     $Pdf = new CakePdf(['engine' => ['className' => 'CakePdf.WkHtmlToPdf', 'options' => ['boolean' => true, 'string' => 'value', 'integer' => 42]]]);
     $result = $method->invokeArgs($Pdf->engine(), []);
     $expected = "/usr/bin/wkhtmltopdf --quiet --print-media-type --orientation 'portrait' --page-size 'A4' --encoding 'UTF-8' --boolean --string 'value' --integer '42' - -";
     $this->assertEquals($expected, $result);
 }
Пример #3
0
 /**
  * Tests that the engine generates the right command
  */
 public function testGetCommand()
 {
     $class = new \ReflectionClass('CakePdf\\Pdf\\Engine\\TexToPdfEngine');
     $method = $class->getMethod('_getCommand');
     $method->setAccessible(true);
     $Pdf = new CakePdf(['engine' => ['className' => 'CakePdf.TexToPdf']]);
     $result = $method->invokeArgs($Pdf->engine(), []);
     if (DS === '\\') {
         $expected = '/usr/bin/latexpdf --output-directory "' . TMP . 'pdf"';
     } else {
         $expected = '/usr/bin/latexpdf --output-directory \'' . TMP . 'pdf\'';
     }
     $this->assertEquals($expected, $result);
 }
Пример #4
0
 /**
  * Tests that engine returns the proper object
  *
  * @dataProvider provider
  */
 public function testEngine($config)
 {
     $pdf = new CakePdf($config);
     $engine = $pdf->engine();
     $this->assertEquals(__NAMESPACE__ . '\\PdfTest2Engine', get_class($engine));
 }