Skip to content

Commit

Permalink
Added bgcolor unit test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hazington committed Jan 3, 2023
1 parent 1a80aac commit a215501
Showing 1 changed file with 47 additions and 37 deletions.
84 changes: 47 additions & 37 deletions tests/PhpWordTests/Style/TextBoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 https://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

Expand All @@ -20,15 +17,15 @@
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.
Expand All @@ -38,23 +35,24 @@ public function testSetGetNormal(): void
$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}";
Expand All @@ -72,23 +70,24 @@ public function testSetStyleValue(): void
$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}";
Expand Down Expand Up @@ -305,4 +304,15 @@ public function testSetGetBorderColor(): void
$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());
}
}

0 comments on commit a215501

Please sign in to comment.