Passed
Branch monitor-2.5.x (8b654c)
by Tim
01:31
created

TestMemcacheServerGroupTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMemcacheServerGroup() 0 28 1
1
<?php
2
3
namespace SimpleSAML\Modules\Monitor\Test;
4
5
use \SimpleSAML\Modules\Monitor\TestCase as TestCase;
6
use \SimpleSAML\Modules\Monitor\TestData as TestData;
7
use \SimpleSAML\Modules\Monitor\TestResult as TestResult;
8
use \SimpleSAML\Modules\Monitor\State as State;
9
10
/**
11
 * Tests for MemcacheServerGroup
12
 */
13
class TestMemcacheServerGroupTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testMemcacheServerGroup()
16
    {
17
        $a = new TestResult();
18
        $a->setState(State::OK);
19
20
        $b = new TestResult();
21
        $b->setState(State::ERROR);
22
23
        $testData = new TestData([
24
            'results' => array($a, $a),
25
        ]);
26
        $testCase = new TestCase\Store\Memcache\ServerGroup($testData);
27
        $testResult = $testCase->getTestResult();
28
        $this->assertEquals(State::OK, $testResult->getState());
29
30
        $testData = new TestData([
31
            'results' => array($a, $b),
32
        ]);
33
        $testCase = new TestCase\Store\Memcache\ServerGroup($testData);
34
        $testResult = $testCase->getTestResult();
35
        $this->assertEquals(State::WARNING, $testResult->getState());
36
37
        $testData = new TestData([
38
            'results' => array($b, $b),
39
        ]);
40
        $testCase = new TestCase\Store\Memcache\ServerGroup($testData);
41
        $testResult = $testCase->getTestResult();
42
        $this->assertEquals(State::ERROR, $testResult->getState());
43
    }
44
}
45