parent
a0165701c7
commit
27b7d67cc9
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPWord_Template;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass PHPWord_Template
|
||||
*/
|
||||
class PHPWord_TemplateTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @test
|
||||
*/
|
||||
final public function testXslStyleSheetCanBeApplied()
|
||||
{
|
||||
// TODO: implement after merge of the issue https://github.com/PHPOffice/PHPWord/issues/56
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Could not set values for the given XSL style sheet parameters.
|
||||
* @test
|
||||
*/
|
||||
final public function testXsLStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue()
|
||||
{
|
||||
$template = new PHPWord_Template(
|
||||
\join(\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx'))
|
||||
);
|
||||
|
||||
$xslDOMDocument = new \DOMDocument();
|
||||
$xslDOMDocument->load(
|
||||
\join(\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl'))
|
||||
);
|
||||
|
||||
$template->applyXslStyleSheet($xslDOMDocument, [1 => 'somevalue']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Could not load XML from the given template.
|
||||
* @test
|
||||
*/
|
||||
final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate()
|
||||
{
|
||||
$template = new PHPWord_Template(
|
||||
\join(\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'corrupted_main_document_part.docx'))
|
||||
);
|
||||
|
||||
$xslDOMDocument = new \DOMDocument();
|
||||
$xslDOMDocument->load(
|
||||
\join(\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl'))
|
||||
);
|
||||
|
||||
$template->applyXslStyleSheet($xslDOMDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Could not transform the given XML document.
|
||||
* @test
|
||||
*/
|
||||
final public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation()
|
||||
{
|
||||
$template = new PHPWord_Template(
|
||||
\join(\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx'))
|
||||
);
|
||||
|
||||
$xslDOMDocument = new \DOMDocument();
|
||||
$xslDOMDocument->load(
|
||||
\join(\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'blank.xsl'))
|
||||
);
|
||||
|
||||
$template->applyXslStyleSheet($xslDOMDocument);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
||||
|
||||
<xsl:template match='@*|node()'>
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select='@*|node()'/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Loading…
Reference in New Issue