Code formatting for PSR1 & PSR2 - Part 2
This commit is contained in:
parent
4e3450e39f
commit
d2a231799d
|
|
@ -69,7 +69,7 @@ class PHPWord_HashTable
|
|||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} else if (!is_array($pSource)) {
|
||||
} elseif (!is_array($pSource)) {
|
||||
throw new Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ class PHPWord_HashTable
|
|||
$hashIndex = $pSource->getHashIndex();
|
||||
if (is_null($hashIndex)) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} else if (isset ($this->_keyMap[$hashIndex])) {
|
||||
} elseif (isset ($this->_keyMap[$hashIndex])) {
|
||||
$hashCode = $this->_keyMap[$hashIndex];
|
||||
} else {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
}
|
||||
|
||||
$objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
} elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
ob_start();
|
||||
call_user_func(
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
|
|||
$objWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
|
||||
$objWriter->endElement();
|
||||
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
} elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use PHPWord_Shared_Drawing;
|
|||
*/
|
||||
class DrawingTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test unit conversion functions with various numbers
|
||||
*/
|
||||
|
|
@ -65,5 +64,4 @@ class DrawingTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($value[1], $result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,13 +12,13 @@ use PHPWord_Shared_File;
|
|||
*/
|
||||
class FileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test file_exists()
|
||||
*/
|
||||
public function testFile_exists()
|
||||
public function testFileExists()
|
||||
{
|
||||
$dir = join(DIRECTORY_SEPARATOR,
|
||||
$dir = join(
|
||||
DIRECTORY_SEPARATOR,
|
||||
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')
|
||||
);
|
||||
chdir($dir);
|
||||
|
|
@ -30,12 +30,13 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testRealpath()
|
||||
{
|
||||
$dir = join(DIRECTORY_SEPARATOR,
|
||||
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
|
||||
$dir = join(
|
||||
DIRECTORY_SEPARATOR,
|
||||
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')
|
||||
);
|
||||
chdir($dir);
|
||||
$file = 'blank.docx';
|
||||
$expected = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
$this->assertEquals($expected, PHPWord_Shared_File::realpath($file));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use PHPWord_Shared_String;
|
|||
*/
|
||||
class StringTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test getIsMbstringEnabled() and getIsIconvEnabled()
|
||||
*/
|
||||
|
|
@ -41,5 +40,4 @@ class StringTest extends \PHPUnit_Framework_TestCase
|
|||
$returned = PHPWord_Shared_String::FormatNumber('1022.1234');
|
||||
$this->assertEquals($expected, $returned);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use PHPWord_Style_Cell;
|
|||
*/
|
||||
class CellTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test setting style with normal value
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use PHPWord_Style_Image;
|
|||
*/
|
||||
class ImageTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test setting style with normal value
|
||||
*/
|
||||
|
|
@ -67,5 +66,4 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||
$object = new PHPWord_Style_Image();
|
||||
$object->setWrappingStyle('foo');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ use PHPWord_Style_ListItem;
|
|||
*/
|
||||
class ListItemTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test construct
|
||||
*/
|
||||
|
|
@ -47,5 +46,4 @@ class ListItemTest extends \PHPUnit_Framework_TestCase
|
|||
$object->setListType($value);
|
||||
$this->assertEquals($value, $object->getListType());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -133,5 +133,4 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
|
|||
$object->setLineHeight('12.5pt');
|
||||
$this->assertEquals(12.5, $object->getLineHeight());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ use PHPWord_Style_Row;
|
|||
*/
|
||||
class RowTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test properties with normal value
|
||||
*/
|
||||
|
|
@ -39,5 +38,4 @@ class RowTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($expected, $object->$get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use PHPWord_Style_TOC;
|
|||
*/
|
||||
class TOCTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test properties with normal value
|
||||
*/
|
||||
|
|
@ -37,5 +36,4 @@ class TOCTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals(null, $object->$get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use PHPWord_Style_TableFull;
|
|||
*/
|
||||
class TableFullTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test class construction
|
||||
*
|
||||
|
|
@ -132,5 +131,4 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
$this->assertEquals($values, $object->getCellMargin());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use PHPWord_Style_Table;
|
|||
*/
|
||||
class TableTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test set style value
|
||||
*/
|
||||
|
|
@ -50,5 +49,4 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
$this->assertEquals($values, $object->getCellMargin());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,5 +42,4 @@ class TabsTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals(1440, $element->getAttribute('w:pos'));
|
||||
$this->assertEquals('dot', $element->getAttribute('w:leader'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
TestHelperDOCX::clear();
|
||||
}
|
||||
|
||||
public function testWriteImage_Position()
|
||||
public function testWriteImagePosition()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
|
|
@ -42,7 +42,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertRegExp('/position:absolute;/', $style);
|
||||
}
|
||||
|
||||
public function testWriteParagraphStyle_Align()
|
||||
public function testWriteParagraphStyleAlign()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
|
|
@ -55,34 +55,10 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('right', $element->getAttribute('w:val'));
|
||||
}
|
||||
|
||||
public function testWriteCellStyle_CellGridSpan()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
|
||||
$table = $section->addTable();
|
||||
|
||||
$table->addRow();
|
||||
$cell = $table->addCell(200);
|
||||
$cell->getStyle()->setGridSpan(5);
|
||||
|
||||
$table->addRow();
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
|
||||
|
||||
$this->assertEquals(5, $element->getAttribute('w:val'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test write paragraph pagination
|
||||
*/
|
||||
public function testWriteParagraphStyle_Pagination()
|
||||
public function testWriteParagraphStylePagination()
|
||||
{
|
||||
// Create the doc
|
||||
$PHPWord = new PHPWord();
|
||||
|
|
@ -108,4 +84,28 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($expected, $element->getAttribute('w:val'));
|
||||
}
|
||||
}
|
||||
|
||||
public function testWriteCellStyleCellGridSpan()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
|
||||
$table = $section->addTable();
|
||||
|
||||
$table->addRow();
|
||||
$cell = $table->addCell(200);
|
||||
$cell->getStyle()->setGridSpan(5);
|
||||
|
||||
$table->addRow();
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
|
||||
|
||||
$this->assertEquals(5, $element->getAttribute('w:val'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
TestHelperDOCX::clear();
|
||||
}
|
||||
|
||||
public function testWriteEndSection_PageNumbering()
|
||||
public function testWriteEndSectionPageNumbering()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class TestHelperDOCX
|
|||
public static function getDocument(PHPWord $PHPWord)
|
||||
{
|
||||
self::$file = tempnam(sys_get_temp_dir(), 'PHPWord');
|
||||
if(!is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
|
||||
mkdir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
||||
if (!is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) {
|
||||
mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
|
||||
}
|
||||
|
||||
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
|
|
@ -29,16 +29,16 @@ class TestHelperDOCX
|
|||
$zip->close();
|
||||
}
|
||||
|
||||
return new Xml_Document(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
||||
return new Xml_Document(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
|
||||
}
|
||||
|
||||
public static function clear()
|
||||
{
|
||||
if(file_exists(self::$file)){
|
||||
unlink(self::$file);
|
||||
if (file_exists(self::$file)) {
|
||||
unlink(self::$file);
|
||||
}
|
||||
if(is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
|
||||
self::deleteDir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
||||
if (is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) {
|
||||
self::deleteDir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,9 +94,9 @@ class Xml_Document
|
|||
}
|
||||
|
||||
$this->xpath = null;
|
||||
$this->file = $file;
|
||||
$this->file = $file;
|
||||
|
||||
$file = $this->path . '/' . $file;
|
||||
$file = $this->path . '/' . $file;
|
||||
$this->dom = new DOMDocument();
|
||||
$this->dom->load($file);
|
||||
return $this->dom;
|
||||
|
|
|
|||
Loading…
Reference in New Issue