Skip to content

Commit

Permalink
Correction error in full api render, added test
Browse files Browse the repository at this point in the history
  • Loading branch information
MolbioUnige committed Aug 25, 2022
1 parent 95b230f commit 426f73e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/View/PhpWordView.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function render($view = null, $layout = null)
$this->PhpWord = new PhpWord();
$this->_ext = '.ctp';
$content = parent::render($view, false);
if ($this->response->type() == 'text/html') {
if ($this->response->getType() == 'text/html') {
return $content;
}
$this->Blocks->set('content', $this->output());
Expand Down Expand Up @@ -158,7 +158,7 @@ protected function serialize()
protected function output()
{
$writer = IOFactory::createWriter($this->PhpWord, 'Word2007');
if (!isset($$writer)) {
if (!isset($writer)) {
throw new Exception('Word writer not found');
}

Expand Down
16 changes: 16 additions & 0 deletions tests/TestCase/View/PhpWordViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,20 @@ public function testRenderCustomFilename()
$this->view->getResponse()->getHeaderLine('Content-Disposition')
);
}

/**
* TestRenderFull
*/
public function testRenderFull()
{
$this->view->render(false);
$this->assertSame(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
$this->view->getResponse()->getType()
);
$this->assertContains(
'filename="blank"',
$this->view->getResponse()->getHeaderLine('Content-Disposition')
);
}
}
3 changes: 3 additions & 0 deletions tests/test_app/TestApp/Template/Imprimaturs/docx/view.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$section = $this->PhpWord->addSection();
$section->addText('Hello World!');

0 comments on commit 426f73e

Please sign in to comment.