79 lines
2.0 KiB
PHP
Raw Normal View History

2014-03-09 19:09:22 +01:00
<?php
2014-03-27 23:55:06 +07:00
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http://www.gnu.org/licenses/lgpl.txt LGPL
2014-03-27 23:55:06 +07:00
*/
namespace PhpOffice\PhpWord\Tests\Element;
2014-03-09 19:09:22 +01: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
/**
* 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()
{
$oText = new Text();
2014-03-09 15:04:23 -04:00
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $oText);
2014-03-09 15:24:13 -04:00
$this->assertEquals(null, $oText->getText());
$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()
{
$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()
{
$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));
$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()
{
$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));
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
2014-03-09 15:04:23 -04:00
}
}