2
2
/**
3
3
* This file is part of PHPWord - A pure PHP library for reading and writing
4
4
* word processing documents.
5
- *
6
5
* PHPWord is free software distributed under the terms of the GNU Lesser
7
6
* General Public License version 3 as published by the Free Software Foundation.
8
- *
9
7
* For the full copyright and license information, please read the LICENSE
10
8
* file that was distributed with this source code. For the full list of
11
9
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
12
10
*
13
11
* @see https://github.com/PHPOffice/PHPWord
14
- *
15
12
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16
13
*/
17
14
20
17
use InvalidArgumentException ;
21
18
use PhpOffice \PhpWord \SimpleType \Jc ;
22
19
use PhpOffice \PhpWord \Style \TextBox ;
20
+ use PHPUnit \Framework \TestCase ;
23
21
24
22
/**
25
23
* Test class for PhpOffice\PhpWord\Style\Image.
26
24
*
27
25
* @coversDefaultClass \PhpOffice\PhpWord\Style\Image
28
- *
29
26
* @runTestsInSeparateProcesses
30
27
*/
31
- class TextBoxTest extends \ PHPUnit \ Framework \ TestCase
28
+ class TextBoxTest extends TestCase
32
29
{
33
30
/**
34
31
* Test setting style with normal value.
@@ -38,23 +35,24 @@ public function testSetGetNormal(): void
38
35
$ object = new TextBox ();
39
36
40
37
$ 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 ' ,
54
51
'innerMarginBottom ' => '5 ' ,
55
- 'innerMarginLeft ' => '5 ' ,
56
- 'borderSize ' => '2 ' ,
57
- 'borderColor ' => 'red ' ,
52
+ 'innerMarginLeft ' => '5 ' ,
53
+ 'borderSize ' => '2 ' ,
54
+ 'borderColor ' => 'red ' ,
55
+ 'bgColor ' => 'blue ' ,
58
56
];
59
57
foreach ($ properties as $ key => $ value ) {
60
58
$ set = "set {$ key }" ;
@@ -72,23 +70,24 @@ public function testSetStyleValue(): void
72
70
$ object = new TextBox ();
73
71
74
72
$ 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 ' ,
88
86
'innerMarginBottom ' => '5 ' ,
89
- 'innerMarginLeft ' => '5 ' ,
90
- 'borderSize ' => '2 ' ,
91
- 'borderColor ' => 'red ' ,
87
+ 'innerMarginLeft ' => '5 ' ,
88
+ 'borderSize ' => '2 ' ,
89
+ 'borderColor ' => 'red ' ,
90
+ 'bgColor ' => 'blue ' ,
92
91
];
93
92
foreach ($ properties as $ key => $ value ) {
94
93
$ get = "get {$ key }" ;
@@ -305,4 +304,15 @@ public function testSetGetBorderColor(): void
305
304
$ object ->setBorderColor ($ expected );
306
305
self ::assertEquals ($ expected , $ object ->getBorderColor ());
307
306
}
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
+ }
308
318
}
0 commit comments