1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CarlosIO\Geckoboard\Tests\Widgets; |
4
|
|
|
|
5
|
|
|
use CarlosIO\Geckoboard\Data\Entry; |
6
|
|
|
use CarlosIO\Geckoboard\Widgets\GeckoMeter; |
7
|
|
|
|
8
|
|
|
class GeckoMeterTest extends \PHPUnit_Framework_TestCase |
9
|
|
|
{ |
10
|
|
|
public function testRevesed() |
11
|
|
|
{ |
12
|
|
|
$myGeckoMeter = new GeckoMeter(); |
13
|
|
|
|
14
|
|
|
$this->assertFalse($myGeckoMeter->getReversed()); |
15
|
|
|
|
16
|
|
|
$myGeckoMeter->setReversed(true); |
17
|
|
|
|
18
|
|
|
$this->assertTrue($myGeckoMeter->getReversed()); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testValue() |
22
|
|
|
{ |
23
|
|
|
$myGeckoMeter = new GeckoMeter(); |
24
|
|
|
|
25
|
|
|
$this->assertNull($myGeckoMeter->getValue()); |
26
|
|
|
|
27
|
|
|
$myGeckoMeter->setValue('value'); |
28
|
|
|
|
29
|
|
|
$this->assertSame('value', $myGeckoMeter->getValue()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testMinMaxData() |
33
|
|
|
{ |
34
|
|
|
$myGeckoMeter = new GeckoMeter(); |
35
|
|
|
|
36
|
|
|
$entry = new Entry(); |
37
|
|
|
|
38
|
|
|
$myGeckoMeter->setMinData($entry); |
39
|
|
|
$myGeckoMeter->setMaxData($entry); |
40
|
|
|
|
41
|
|
|
$this->assertSame($entry, $myGeckoMeter->getMinData()); |
42
|
|
|
$this->assertSame($entry, $myGeckoMeter->getMaxData()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testEntryException() |
46
|
|
|
{ |
47
|
|
|
$myGeckoMeter = new GeckoMeter(); |
48
|
|
|
|
49
|
|
|
$this->setExpectedException('\Exception'); |
|
|
|
|
50
|
|
|
|
51
|
|
|
$myGeckoMeter->getMinData(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testGetData() |
55
|
|
|
{ |
56
|
|
|
$myGeckoMeter = new GeckoMeter(); |
57
|
|
|
|
58
|
|
|
$entry = new Entry(); |
59
|
|
|
$entry->setValue(10); |
60
|
|
|
$entry->setPrefix(''); |
61
|
|
|
$entry->setText('text'); |
62
|
|
|
|
63
|
|
|
$myGeckoMeter->setReversed(true); |
64
|
|
|
$myGeckoMeter->setValue(10); |
65
|
|
|
$myGeckoMeter->setMinData($entry); |
66
|
|
|
$myGeckoMeter->setMaxData($entry); |
67
|
|
|
|
68
|
|
|
$expectedData = array( |
69
|
|
|
'item' => $myGeckoMeter->getValue(), |
70
|
|
|
'max' => array( |
71
|
|
|
'text' => $entry->getText(), |
72
|
|
|
'value' => $entry->getValue(), |
73
|
|
|
'prefix' => $entry->getPrefix(), |
74
|
|
|
), |
75
|
|
|
'min' => array( |
76
|
|
|
'text' => $entry->getText(), |
77
|
|
|
'value' => $entry->getValue(), |
78
|
|
|
'prefix' => $entry->getPrefix(), |
79
|
|
|
), |
80
|
|
|
'type' => 'reversed', |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
$this->assertSame($expectedData, $myGeckoMeter->getData()); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.