Test folder updated
Test folder updated for new file CheckBoxText
This commit is contained in:
parent
258c9c6b9e
commit
ab6503eb0d
|
|
@ -128,6 +128,7 @@ class PHPWord_Section
|
|||
/**
|
||||
* Add a CheckBox Element
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $text
|
||||
* @param mixed $style
|
||||
* @return PHPWord_Section_CheckBox
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class PHPWord_Section_CheckBox
|
|||
/**
|
||||
* Create a new Text Element
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $text
|
||||
* @param null|array|\PHPWord_Style_Font $fontStyle
|
||||
* @param null|array|\PHPWord_Style_Paragraph $paragraphStyle
|
||||
|
|
@ -149,9 +150,9 @@ class PHPWord_Section_CheckBox
|
|||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($text)
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $text;
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ class PHPWord_Section_Table_Cell
|
|||
/**
|
||||
* Add a CheckBox Element
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $text
|
||||
* @param mixed $style
|
||||
* @return PHPWord_Section_CheckBox
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class PHPWord_Section_Text
|
|||
$this->text = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Text content
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPWord;
|
||||
use PHPWord_Autoloader;
|
||||
use PHPWord_Autoloader as Autoloader;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests\Section;
|
||||
|
||||
use PHPWord081_PHPWord_Section_CheckBox;
|
||||
|
||||
class CheckBoxTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$oCheckBox = new PHPWord081_PHPWord_Section_CheckBox();
|
||||
|
||||
$this->assertInstanceOf('PHPWord_Section_CheckBox', $oCheckBox);
|
||||
$this->assertEquals(null, $oCheckBox->getText());
|
||||
$this->assertInstanceOf('PHPWord_Style_Font', $oCheckBox->getFontStyle());
|
||||
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oCheckBox->getParagraphStyle());
|
||||
}
|
||||
|
||||
public function testCheckBox()
|
||||
{
|
||||
$oCheckBox = new PHPWord_Section_CheckBox('CheckBox');
|
||||
|
||||
$this->assertEquals($oCheckBox->getText(), 'CheckBox');
|
||||
}
|
||||
|
||||
public function testFont()
|
||||
{
|
||||
$oCheckBox = new PHPWord_Section_CheckBox('CheckBox', 'fontStyle');
|
||||
$this->assertEquals($oCheckBox->getFontStyle(), 'fontStyle');
|
||||
|
||||
$oCheckBox->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16));
|
||||
$this->assertInstanceOf('PHPWord_Style_Font', $oCheckBox->getFontStyle());
|
||||
}
|
||||
|
||||
public function testParagraph()
|
||||
{
|
||||
$oCheckBox = new PHPWord_Section_CheckBox('CheckBox', 'fontStyle', 'paragraphStyle');
|
||||
$this->assertEquals($oCheckBox->getParagraphStyle(), 'paragraphStyle');
|
||||
|
||||
$oCheckBox->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
|
||||
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oCheckBox->getParagraphStyle());
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,15 @@ class CellTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertInstanceOf('PHPWord_Section_Text', $element);
|
||||
}
|
||||
|
||||
public function testaddCheckBox()
|
||||
{
|
||||
$oCell = new PHPWord_Section_Table_Cell('section', 1);
|
||||
$element = $oCell->addCheckBox('check1', 'text');
|
||||
|
||||
$this->assertCount(1, $oCell->getElements());
|
||||
$this->assertInstanceOf('PHPWord_Section_CheckBox', $element);
|
||||
}
|
||||
|
||||
public function testAddTextNotUTF8()
|
||||
{
|
||||
$oCell = new PHPWord_Section_Table_Cell('section', 1);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* @covers PHPWord_Section::addText
|
||||
* @covers PHPWord_Section::addCheckBox
|
||||
* @covers PHPWord_Section::addLink
|
||||
* @covers PHPWord_Section::addTextBreak
|
||||
* @covers PHPWord_Section::addPageBreak
|
||||
|
|
@ -88,6 +89,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$section = new PHPWord_Section(0);
|
||||
$section->addText(utf8_decode('ä'));
|
||||
$section->addCheckBox('check1', utf8_decode('ä'));
|
||||
$section->addLink(utf8_decode('http://äää.com'), utf8_decode('ä'));
|
||||
$section->addTextBreak();
|
||||
$section->addPageBreak();
|
||||
|
|
|
|||
|
|
@ -43,6 +43,26 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($pStyle, $doc->getElementAttribute($element, 'w:val'));
|
||||
}
|
||||
|
||||
/**
|
||||
* covers ::_writeCheckbox
|
||||
*/
|
||||
public function testWriteCheckbox()
|
||||
{
|
||||
$rStyle = 'rStyle';
|
||||
$pStyle = 'pStyle';
|
||||
|
||||
$PHPWord = new PHPWord();
|
||||
$PHPWord->addFontStyle($rStyle, array('bold' => true));
|
||||
$PHPWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120));
|
||||
$section = $PHPWord->createSection();
|
||||
$section->addCheckbox('Check1', 'Test', $rStyle, $pStyle);
|
||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||
|
||||
$element = $doc->getElement('/w:document/w:body/w:p/w:checkbox/w:r/w:t');
|
||||
|
||||
$this->assertEquals($expected, $element->nodeValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* covers ::_writeTextRun
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue