Added bgcolor unit test coverage

This commit is contained in:
hazington 2023-01-03 23:35:37 +01:00
parent 1a80aacb4f
commit a215501cc9

View File

@ -2,16 +2,13 @@
/** /**
* This file is part of PHPWord - A pure PHP library for reading and writing * This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents. * word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser * PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation. * General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE * For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of * file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
@ -20,15 +17,15 @@ namespace PhpOffice\PhpWordTests\Style;
use InvalidArgumentException; use InvalidArgumentException;
use PhpOffice\PhpWord\SimpleType\Jc; use PhpOffice\PhpWord\SimpleType\Jc;
use PhpOffice\PhpWord\Style\TextBox; use PhpOffice\PhpWord\Style\TextBox;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for PhpOffice\PhpWord\Style\Image. * Test class for PhpOffice\PhpWord\Style\Image.
* *
* @coversDefaultClass \PhpOffice\PhpWord\Style\Image * @coversDefaultClass \PhpOffice\PhpWord\Style\Image
*
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class TextBoxTest extends \PHPUnit\Framework\TestCase class TextBoxTest extends TestCase
{ {
/** /**
* Test setting style with normal value. * Test setting style with normal value.
@ -38,23 +35,24 @@ class TextBoxTest extends \PHPUnit\Framework\TestCase
$object = new TextBox(); $object = new TextBox();
$properties = [ $properties = [
'width' => 200, 'width' => 200,
'height' => 200, 'height' => 200,
'alignment' => Jc::START, 'alignment' => Jc::START,
'marginTop' => 240, 'marginTop' => 240,
'marginLeft' => 240, 'marginLeft' => 240,
'wrappingStyle' => 'inline', 'wrappingStyle' => 'inline',
'positioning' => 'absolute', 'positioning' => 'absolute',
'posHorizontal' => 'center', 'posHorizontal' => 'center',
'posVertical' => 'top', 'posVertical' => 'top',
'posHorizontalRel' => 'margin', 'posHorizontalRel' => 'margin',
'posVerticalRel' => 'page', 'posVerticalRel' => 'page',
'innerMarginTop' => '5', 'innerMarginTop' => '5',
'innerMarginRight' => '5', 'innerMarginRight' => '5',
'innerMarginBottom' => '5', 'innerMarginBottom' => '5',
'innerMarginLeft' => '5', 'innerMarginLeft' => '5',
'borderSize' => '2', 'borderSize' => '2',
'borderColor' => 'red', 'borderColor' => 'red',
'bgColor' => 'blue',
]; ];
foreach ($properties as $key => $value) { foreach ($properties as $key => $value) {
$set = "set{$key}"; $set = "set{$key}";
@ -72,23 +70,24 @@ class TextBoxTest extends \PHPUnit\Framework\TestCase
$object = new TextBox(); $object = new TextBox();
$properties = [ $properties = [
'width' => 200, 'width' => 200,
'height' => 200, 'height' => 200,
'alignment' => Jc::START, 'alignment' => Jc::START,
'marginTop' => 240, 'marginTop' => 240,
'marginLeft' => 240, 'marginLeft' => 240,
'wrappingStyle' => 'inline', 'wrappingStyle' => 'inline',
'positioning' => 'absolute', 'positioning' => 'absolute',
'posHorizontal' => 'center', 'posHorizontal' => 'center',
'posVertical' => 'top', 'posVertical' => 'top',
'posHorizontalRel' => 'margin', 'posHorizontalRel' => 'margin',
'posVerticalRel' => 'page', 'posVerticalRel' => 'page',
'innerMarginTop' => '5', 'innerMarginTop' => '5',
'innerMarginRight' => '5', 'innerMarginRight' => '5',
'innerMarginBottom' => '5', 'innerMarginBottom' => '5',
'innerMarginLeft' => '5', 'innerMarginLeft' => '5',
'borderSize' => '2', 'borderSize' => '2',
'borderColor' => 'red', 'borderColor' => 'red',
'bgColor' => 'blue',
]; ];
foreach ($properties as $key => $value) { foreach ($properties as $key => $value) {
$get = "get{$key}"; $get = "get{$key}";
@ -305,4 +304,15 @@ class TextBoxTest extends \PHPUnit\Framework\TestCase
$object->setBorderColor($expected); $object->setBorderColor($expected);
self::assertEquals($expected, $object->getBorderColor()); self::assertEquals($expected, $object->getBorderColor());
} }
/**
* Test set/get bgColor.
*/
public function testSetGetBgColor(): void
{
$expected = 'blue';
$object = new TextBox();
$object->setBgColor($expected);
self::assertEquals($expected, $object->getBgColor());
}
} }