GeckoMeterTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 5
c 3
b 1
f 1
lcom 1
cbo 3
dl 0
loc 78
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testRevesed() 0 10 1
A testValue() 0 10 1
A testMinMaxData() 0 12 1
A testEntryException() 0 8 1
B testGetData() 0 31 1
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');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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.

Loading history...
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