Skip to content

Commit 3d8f09d

Browse files
committed
PHPWord_Style_CellTest 100% code coverage
1 parent fa1663a commit 3d8f09d

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

Tests/PHPWord/Style/CellTest.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
namespace PHPWord\Tests;
3+
4+
use PHPUnit_Framework_TestCase;
5+
use PHPWord_Style_Cell;
6+
7+
/**
8+
* Class PHPWord_Style_CellTest
9+
*
10+
* @package PHPWord\Tests
11+
* @runTestsInSeparateProcesses
12+
*/
13+
class PHPWord_Style_CellTest extends \PHPUnit_Framework_TestCase
14+
{
15+
16+
/**
17+
* Test setting style with normal value
18+
*/
19+
public function testSetGetNormal()
20+
{
21+
$object = new PHPWord_Style_Cell();
22+
23+
$attributes = array(
24+
'valign' => null,
25+
'textDirection' => null,
26+
'bgColor' => null,
27+
'borderTopSize' => null,
28+
'borderTopColor' => null,
29+
'borderLeftSize' => null,
30+
'borderLeftColor' => null,
31+
'borderRightSize' => null,
32+
'borderRightColor' => null,
33+
'borderBottomSize' => null,
34+
'borderBottomColor' => null,
35+
'gridSpan' => null,
36+
'vMerge' => null,
37+
);
38+
//'defaultBorderColor' => null,
39+
foreach ($attributes as $key => $value) {
40+
$set = "set{$key}";
41+
$get = "get{$key}";
42+
$object->$set($value);
43+
$this->assertEquals($value, $object->$get());
44+
}
45+
}
46+
47+
/**
48+
* Test border color
49+
*/
50+
public function testBorderColor()
51+
{
52+
$object = new PHPWord_Style_Cell();
53+
54+
$default = '000000';
55+
$value = 'FF0000';
56+
57+
$this->assertEquals($default, $object->getDefaultBorderColor());
58+
59+
$object->setStyleValue('_defaultBorderColor', $value);
60+
$this->assertEquals($value, $object->getDefaultBorderColor());
61+
62+
$object->setStyleValue('_borderColor', $value);
63+
$expected = array($value, $value, $value, $value);
64+
$this->assertEquals($expected, $object->getBorderColor());
65+
}
66+
67+
/**
68+
* Test border size
69+
*/
70+
public function testBorderSize()
71+
{
72+
$object = new PHPWord_Style_Cell();
73+
74+
$value = 120;
75+
$expected = array($value, $value, $value, $value);
76+
$object->setStyleValue('_borderSize', $value);
77+
$this->assertEquals($expected, $object->getBorderSize());
78+
}
79+
80+
}

0 commit comments

Comments
 (0)