/**
  * testPluginOutput
  *
  * @dataProvider provider
  */
 public function testPluginOutput($config)
 {
     $pdf = new CakePdf($config);
     $path = CakePlugin::path('CakePdf') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS;
     App::build(array('Plugin' => $path));
     CakePlugin::load('MyPlugin');
     $pdf->viewVars(array('data' => 'testing'));
     $pdf->template('MyPlugin.testing', 'MyPlugin.pdf');
     $pdf->helpers('MyPlugin.MyTest');
     $result = $pdf->output();
     $expected = 'MyPlugin Layout Data: testing';
     $this->assertEquals($expected, $result);
     $pdf->template('MyPlugin.testing', 'MyPlugin.default');
     $result = $pdf->output();
     $lines = array('<h2>Rendered with default layout from MyPlugin</h2>', 'MyPlugin view Data: testing', 'MyPlugin Helper Test: successful');
     foreach ($lines as $line) {
         $this->assertTrue(strpos($result, $line) !== false);
     }
 }
 public function download()
 {
     App::uses('CakePdf', 'Plugin/CakePdf/Pdf');
     $CakePdf = new CakePdf();
     $CakePdf->template('teste', 'default');
     $CakePdf->viewVars(array('nome' => 'Thiago'));
     $CakePdf->output();
     $path = WWW_ROOT . DS . 'files' . DS;
     $path .= uniqid() . '.pdf';
     if ($CakePdf->write($path)) {
         $this->response->file($path, array('download' => true, 'name' => 'teste_' . uniqid()));
         return $this->response;
     }
 }
예제 #3
0
 /**
  * testOutput
  *
  * @dataProvider provider
  */
 public function testOutput($config)
 {
     $pdf = new CakePdf($config);
     $path = CakePlugin::path('CakePdf') . 'Test' . DS . 'test_app' . DS . 'View' . DS;
     App::build(array('View' => $path));
     $pdf->viewVars(array('data' => 'testing'));
     $pdf->template('testing', 'pdf');
     $result = $pdf->output();
     $expected = 'Data: testing';
     $this->assertEquals($expected, $result);
     $html = '<h2>Title</h2>';
     $result = $pdf->output($html);
     $this->assertEquals($html, $result);
 }