Skip to content

Commit a215501

Browse files
author
hazington
committed
Added bgcolor unit test coverage
1 parent 1a80aac commit a215501

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

tests/PhpWordTests/Style/TextBoxTest.php

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
/**
33
* This file is part of PHPWord - A pure PHP library for reading and writing
44
* word processing documents.
5-
*
65
* PHPWord is free software distributed under the terms of the GNU Lesser
76
* General Public License version 3 as published by the Free Software Foundation.
8-
*
97
* For the full copyright and license information, please read the LICENSE
108
* file that was distributed with this source code. For the full list of
119
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
1210
*
1311
* @see https://github.com/PHPOffice/PHPWord
14-
*
1512
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1613
*/
1714

@@ -20,15 +17,15 @@
2017
use InvalidArgumentException;
2118
use PhpOffice\PhpWord\SimpleType\Jc;
2219
use PhpOffice\PhpWord\Style\TextBox;
20+
use PHPUnit\Framework\TestCase;
2321

2422
/**
2523
* Test class for PhpOffice\PhpWord\Style\Image.
2624
*
2725
* @coversDefaultClass \PhpOffice\PhpWord\Style\Image
28-
*
2926
* @runTestsInSeparateProcesses
3027
*/
31-
class TextBoxTest extends \PHPUnit\Framework\TestCase
28+
class TextBoxTest extends TestCase
3229
{
3330
/**
3431
* Test setting style with normal value.
@@ -38,23 +35,24 @@ public function testSetGetNormal(): void
3835
$object = new TextBox();
3936

4037
$properties = [
41-
'width' => 200,
42-
'height' => 200,
43-
'alignment' => Jc::START,
44-
'marginTop' => 240,
45-
'marginLeft' => 240,
46-
'wrappingStyle' => 'inline',
47-
'positioning' => 'absolute',
48-
'posHorizontal' => 'center',
49-
'posVertical' => 'top',
50-
'posHorizontalRel' => 'margin',
51-
'posVerticalRel' => 'page',
52-
'innerMarginTop' => '5',
53-
'innerMarginRight' => '5',
38+
'width' => 200,
39+
'height' => 200,
40+
'alignment' => Jc::START,
41+
'marginTop' => 240,
42+
'marginLeft' => 240,
43+
'wrappingStyle' => 'inline',
44+
'positioning' => 'absolute',
45+
'posHorizontal' => 'center',
46+
'posVertical' => 'top',
47+
'posHorizontalRel' => 'margin',
48+
'posVerticalRel' => 'page',
49+
'innerMarginTop' => '5',
50+
'innerMarginRight' => '5',
5451
'innerMarginBottom' => '5',
55-
'innerMarginLeft' => '5',
56-
'borderSize' => '2',
57-
'borderColor' => 'red',
52+
'innerMarginLeft' => '5',
53+
'borderSize' => '2',
54+
'borderColor' => 'red',
55+
'bgColor' => 'blue',
5856
];
5957
foreach ($properties as $key => $value) {
6058
$set = "set{$key}";
@@ -72,23 +70,24 @@ public function testSetStyleValue(): void
7270
$object = new TextBox();
7371

7472
$properties = [
75-
'width' => 200,
76-
'height' => 200,
77-
'alignment' => Jc::START,
78-
'marginTop' => 240,
79-
'marginLeft' => 240,
80-
'wrappingStyle' => 'inline',
81-
'positioning' => 'absolute',
82-
'posHorizontal' => 'center',
83-
'posVertical' => 'top',
84-
'posHorizontalRel' => 'margin',
85-
'posVerticalRel' => 'page',
86-
'innerMarginTop' => '5',
87-
'innerMarginRight' => '5',
73+
'width' => 200,
74+
'height' => 200,
75+
'alignment' => Jc::START,
76+
'marginTop' => 240,
77+
'marginLeft' => 240,
78+
'wrappingStyle' => 'inline',
79+
'positioning' => 'absolute',
80+
'posHorizontal' => 'center',
81+
'posVertical' => 'top',
82+
'posHorizontalRel' => 'margin',
83+
'posVerticalRel' => 'page',
84+
'innerMarginTop' => '5',
85+
'innerMarginRight' => '5',
8886
'innerMarginBottom' => '5',
89-
'innerMarginLeft' => '5',
90-
'borderSize' => '2',
91-
'borderColor' => 'red',
87+
'innerMarginLeft' => '5',
88+
'borderSize' => '2',
89+
'borderColor' => 'red',
90+
'bgColor' => 'blue',
9291
];
9392
foreach ($properties as $key => $value) {
9493
$get = "get{$key}";
@@ -305,4 +304,15 @@ public function testSetGetBorderColor(): void
305304
$object->setBorderColor($expected);
306305
self::assertEquals($expected, $object->getBorderColor());
307306
}
307+
308+
/**
309+
* Test set/get bgColor.
310+
*/
311+
public function testSetGetBgColor(): void
312+
{
313+
$expected = 'blue';
314+
$object = new TextBox();
315+
$object->setBgColor($expected);
316+
self::assertEquals($expected, $object->getBgColor());
317+
}
308318
}

0 commit comments

Comments
 (0)