Skip to content

Commit 18c1e5f

Browse files
committed
Additional template test
1 parent 077d87d commit 18c1e5f

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Tests/PHPWord/TemplateTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,43 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT
145145
@$template->applyXslStyleSheet($xslDOMDocument);
146146
}
147147

148+
/**
149+
* @covers PHPWord_Template
150+
*/
151+
public function testConstruct()
152+
{
153+
$template = \join(
154+
\DIRECTORY_SEPARATOR,
155+
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-row.docx')
156+
);
157+
$expectedVar = array('tableHeader', 'userId', 'userName');
158+
$document = new PHPWord_Template($template);
159+
$actualVar = $document->getVariables();
160+
$document->cloneRow('userId', 9);
161+
$document->setValue('userId#1', utf8_decode('ééé'));
162+
$document->setValue('userId#2', 'a');
163+
$document->setValue('userId#3', 'a');
164+
$document->setValue('userId#3', 'a');
165+
$document->setValue('userId#4', 'a');
166+
$document->setValue('userId#5', 'a');
167+
$document->setValue('userId#6', 'a');
168+
$document->setValue('userId#7', 'a');
169+
$document->setValue('userId#8', 'a');
170+
$document->cloneRow('userId#9', 'a');
171+
$this->assertEquals($expectedVar, $actualVar);
172+
}
173+
148174
/**
149175
* @covers ::setValue
150176
* @covers ::getVariables
151177
* @covers ::cloneRow
152178
* @covers ::saveAs
153179
*/
154-
public function testCloneRow()
180+
public function testCloneMergedRow()
155181
{
156182
$template = \join(
157183
\DIRECTORY_SEPARATOR,
158-
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-row.docx')
184+
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-merge.docx')
159185
);
160186
$expectedVar = array('tableHeader', 'userId', 'userName', 'userLocation');
161187
$docName = 'clone-test-result.docx';
14.3 KB
Binary file not shown.

Tests/_files/templates/clone-row.docx

-12 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)