|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CarlosIO\Geckoboard\Tests\Widgets; |
|
4
|
|
|
|
|
5
|
|
|
use CarlosIO\Geckoboard\Data\Entry; |
|
6
|
|
|
|
|
7
|
|
|
class RagNumbersTest extends \PHPUnit_Framework_TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @test |
|
11
|
|
|
* @dataProvider widgetProvider |
|
12
|
|
|
*/ |
|
13
|
|
|
public function jsonForFullData($widgetName) |
|
14
|
|
|
{ |
|
15
|
|
|
$widget = new $widgetName(); |
|
16
|
|
|
$widget->setId('29473-d7ae87e3-ac3f-4911-95ce-ec91439a4170'); |
|
17
|
|
|
|
|
18
|
|
|
$redData = new Entry(); |
|
19
|
|
|
$redData->setValue(15)->setText('Errors in the last 5 minutes'); |
|
20
|
|
|
$widget->setRedData($redData); |
|
21
|
|
|
|
|
22
|
|
|
$amberData = new Entry(); |
|
23
|
|
|
$amberData->setValue(15)->setText('Errors in the last 15 minutes'); |
|
24
|
|
|
$widget->setAmberData($amberData); |
|
25
|
|
|
|
|
26
|
|
|
$greenData = new Entry(); |
|
27
|
|
|
$greenData->setValue(15)->setText('Errors in the last 60 minutes'); |
|
28
|
|
|
$widget->setGreenData($greenData); |
|
29
|
|
|
|
|
30
|
|
|
$json = json_encode($widget->getData()); |
|
31
|
|
|
$this->assertEquals('{"item":[{"text":"Errors in the last 5 minutes","value":15},{"text":"Errors in the last 15 minutes","value":15},{"text":"Errors in the last 60 minutes","value":15}]}', $json); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @test |
|
36
|
|
|
* @dataProvider widgetProvider |
|
37
|
|
|
*/ |
|
38
|
|
|
public function JsonForGreenAndRedData($widgetName) |
|
39
|
|
|
{ |
|
40
|
|
|
$widget = new $widgetName(); |
|
41
|
|
|
|
|
42
|
|
|
$widget->setId('29473-d7ae87e3-ac3f-4911-95ce-ec91439a4170'); |
|
43
|
|
|
|
|
44
|
|
|
$redData = new Entry(); |
|
45
|
|
|
$redData->setValue(15)->setText('Errors in the last 5 minutes'); |
|
46
|
|
|
$widget->setRedData($redData); |
|
47
|
|
|
|
|
48
|
|
|
$greenData = new Entry(); |
|
49
|
|
|
$greenData->setValue(15)->setText('Errors in the last 60 minutes'); |
|
50
|
|
|
$widget->setGreenData($greenData); |
|
51
|
|
|
|
|
52
|
|
|
$json = json_encode($widget->getData()); |
|
53
|
|
|
$this->assertEquals('{"item":[{"text":"Errors in the last 5 minutes","value":15},{"text":"Errors in the last 60 minutes","value":15}]}', $json); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function widgetProvider() |
|
57
|
|
|
{ |
|
58
|
|
|
return array( |
|
59
|
|
|
array('CarlosIO\Geckoboard\Widgets\RagNumbers'), |
|
60
|
|
|
array('CarlosIO\Geckoboard\Widgets\RagColumnAndNumbers'), |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|