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