2014-03-09 19:09:22 +01:00
|
|
|
<?php
|
2014-03-27 23:55:06 +07:00
|
|
|
/**
|
|
|
|
|
* PHPWord
|
|
|
|
|
*
|
|
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
2014-05-05 12:38:31 +04:00
|
|
|
* @copyright 2010-2014 PHPWord contributors
|
2014-05-04 21:03:28 +04:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
2014-03-27 23:55:06 +07:00
|
|
|
*/
|
|
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
namespace PhpOffice\PhpWord\Tests\Element;
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
use PhpOffice\PhpWord\Element\Text;
|
2014-03-30 11:09:14 +07:00
|
|
|
use PhpOffice\PhpWord\Style\Font;
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-27 23:55:06 +07:00
|
|
|
/**
|
2014-03-31 01:13:02 +07:00
|
|
|
* Test class for PhpOffice\PhpWord\Element\Text
|
2014-03-27 23:55:06 +07:00
|
|
|
*
|
|
|
|
|
* @runTestsInSeparateProcesses
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
class TextTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
2014-03-30 11:09:14 +07:00
|
|
|
/**
|
|
|
|
|
* New instance
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testConstruct()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oText = new Text();
|
2014-03-09 15:04:23 -04:00
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $oText);
|
2014-03-09 15:24:13 -04:00
|
|
|
$this->assertEquals(null, $oText->getText());
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle());
|
|
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
|
2014-03-09 15:04:23 -04:00
|
|
|
}
|
|
|
|
|
|
2014-03-30 11:09:14 +07:00
|
|
|
/**
|
|
|
|
|
* Get text
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testText()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oText = new Text('text');
|
2014-03-09 15:04:23 -04:00
|
|
|
|
|
|
|
|
$this->assertEquals($oText->getText(), 'text');
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-30 11:09:14 +07:00
|
|
|
/**
|
|
|
|
|
* Get font style
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testFont()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oText = new Text('text', 'fontStyle');
|
2014-03-09 15:04:23 -04:00
|
|
|
$this->assertEquals($oText->getFontStyle(), 'fontStyle');
|
|
|
|
|
|
|
|
|
|
$oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16));
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle());
|
2014-03-09 15:04:23 -04:00
|
|
|
}
|
|
|
|
|
|
2014-03-30 11:09:14 +07:00
|
|
|
/**
|
|
|
|
|
* Get font style as object
|
|
|
|
|
*/
|
|
|
|
|
public function testFontObject()
|
|
|
|
|
{
|
|
|
|
|
$font = new Font();
|
|
|
|
|
$oText = new Text('text', $font);
|
|
|
|
|
$this->assertEquals($oText->getFontStyle(), $font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get paragraph style
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testParagraph()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oText = new Text('text', 'fontStyle', 'paragraphStyle');
|
2014-03-09 15:04:23 -04:00
|
|
|
$this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle');
|
|
|
|
|
|
|
|
|
|
$oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
|
2014-03-09 15:04:23 -04:00
|
|
|
}
|
2014-03-23 17:37:26 +07:00
|
|
|
}
|