Passed
Branch master (4b23d6)
by Tim
04:40
created

testMemcacheServerGroup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 28
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SimpleSAML\Module\Monitor\Test;
4
5
use SimpleSAML\Module\Monitor\TestCase;
6
use SimpleSAML\Module\Monitor\TestData;
7
use SimpleSAML\Module\Monitor\TestResult;
8
use SimpleSAML\Module\Monitor\State;
9
10
/**
11
 * Tests for MemcacheServerGroup
12
 */
13
class TestMemcacheServerGroupTest extends \PHPUnit\Framework\TestCase
14
{
15
    public function testMemcacheServerGroup(): void
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' => [$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' => [$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' => [$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