#51 (updated tests, refactored a little).

This commit is contained in:
Roman Syroeshko 2015-02-21 18:30:00 +04:00
parent cc305bcb11
commit 4eefb60362
4 changed files with 17 additions and 10 deletions

View File

@ -2,6 +2,14 @@
This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub.
## 0.13.0 - TBD
Place announcement text here.
### Bugfixes
- It was discovered that ``alignment`` option value doesn't affect paragraph alignment at all. This was fixed. Note: ``getAlign()`` and ``setAlign()`` methods of ``Paragraph`` style are renamed. - @RomanSyroeshko
## 0.12.0 - 3 January 2015
This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced.

View File

@ -26,7 +26,6 @@ use PhpOffice\PhpWord\Style\Alignment;
*/
class Paragraph extends AbstractStyle
{
/**
* Depth of table container nested level; Primarily used for RTF writer/reader
*
@ -55,7 +54,7 @@ class Paragraph extends AbstractStyle
Alignment::ALIGN_BOTH => '\qj',
);
$align = $style->getAlign();
$alignment = $style->getAlignment();
$spaceAfter = $style->getSpaceAfter();
$spaceBefore = $style->getSpaceBefore();
@ -63,8 +62,8 @@ class Paragraph extends AbstractStyle
if ($this->nestedLevel == 0) {
$content .= '\pard\nowidctlpar ';
}
if (isset($alignments[$align])) {
$content .= $alignments[$align];
if (!is_null($alignment) && isset($alignments[$alignment->getValue()])) {
$content .= $alignments[$alignment->getValue()];
}
$content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore);
$content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter);

View File

@ -67,7 +67,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
$object = new Paragraph();
$attributes = array(
'align' => 'justify',
// 'align' => 'justify',
'spaceAfter' => 240,
'spaceBefore' => 240,
'indent' => 1,
@ -85,11 +85,11 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
foreach ($attributes as $key => $value) {
$get = "get{$key}";
$object->setStyleValue("$key", $value);
if ('align' == $key) {
/*if ('align' == $key) {
if ('justify' == $value) {
$value = 'both';
}
} elseif ('indent' == $key || 'hanging' == $key) {
} else*/if ('indent' == $key || 'hanging' == $key) {
$value = $value * 720;
} elseif ('spacing' == $key) {
$value += 240;

View File

@ -421,7 +421,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord();
$section = $phpWord->addSection();
$attributes = array(
'align' => 'right',
'alignment' => 'right',
'widowControl' => false,
'keepNext' => true,
'keepLines' => true,
@ -436,9 +436,9 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$attributeCount = 0;
foreach ($attributes as $key => $value) {
$attributeCount++;
$nodeName = ($key == 'align') ? 'jc' : $key;
$nodeName = ($key == 'alignment') ? 'jc' : $key;
$path = "/w:document/w:body/w:p[{$attributeCount}]/w:pPr/w:{$nodeName}";
if ('align' != $key) {
if ('alignment' != $key) {
$value = $value ? 1 : 0;
}
$element = $doc->getElement($path);