/
ReportTest.php
112 lines (100 loc) · 2.7 KB
/
ReportTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
namespace Expose;
class ReportTest extends \PHPUnit_Framework_TestCase
{
private $report = null;
public function setUp()
{
$this->report = new \Expose\Report();
}
/**
* Test the getter/setter for the variable name
*
* @covers \Expose\Report::getVarName
* @covers \Expose\Report::setVarName
*/
public function testGetSetVariableName()
{
$name = 'var1';
$this->report->setVarName($name);
$this->assertEquals(
$this->report->getVarName(),
$name
);
}
/**
* Test the getter/setter for the variable value
*
* @covers \Expose\Report::setVarValue
* @covers \Expose\Report::getVarValue
*/
public function testGetSetVariableValue()
{
$value = 'value1';
$this->report->setVarValue($value);
$this->assertEquals(
$this->report->getVarValue(),
$value
);
}
/**
* Test the getter/setter for the variable path
*
* @covers \Expose\Report::setVarPath
* @covers \Expose\Report::getVarPath
*/
public function testGetSetVariablePath()
{
$value = 'value1';
$this->report->setVarPath($value);
$this->assertEquals(
$this->report->getVarPath(),
$value
);
}
/**
* Test the getter/setter for working with filter matches
*
* @covers \Expose\Report::addFilterMatch
* @covers \Expose\Report::getfilterMatch
*/
public function testGetSetFilterMatch()
{
$matches = array('match1', 'match2');
$this->report->addFilterMatch($matches);
$this->assertEquals(
$matches,
$this->report->getFilterMatch()
);
}
/**
* Convert the object into an array
*
* @covers \Expose\Report::toArray
*/
public function testObjectToArray()
{
$this->report->setVarName('foo');
$this->report->setVarValue('bar');
$result = $this->report->toArray();
$this->assertTrue(
(isset($result['varName']) && $result['varName'] === 'foo')
&& (isset($result['varValue']) && $result['varValue'] === 'bar')
);
}
/**
* Test the "expansion" of filters (converting them to arrays too)
*
* @covers \Expose\Report::toArray
*/
public function testObjectToArrayExpandFilters()
{
$filter = new \Expose\Filter();
$filter->setId(1234);
$this->report->addFilterMatch($filter);
$result = $this->report->toArray(true);
$this->assertTrue(
isset($result['filterMatches'][0]) && $result['filterMatches'][0]['id'] === 1234
);
}
}