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

TestMemcacheServerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMemcacheServerUp() 0 13 1
A testMemcacheServerDown() 0 10 1
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 MemcacheServer
12
 */
13
class TestMemcacheServerTest extends \PHPUnit\Framework\TestCase
14
{
15
    public function testMemcacheServerUp(): void
16
    {
17
        $testData = new TestData([
18
            'serverStats' => ['bytes' => 1024, 'limit_maxbytes' => 2048],
19
            'host' => 'testhost.example.org',
20
        ]);
21
        $testCase = new TestCase\Store\Memcache\Server($testData);
22
23
        $testResult = $testCase->getTestResult();
24
        $testOutput = $testResult->getOutput();
25
26
        $this->assertEquals(State::OK, $testResult->getState());
27
        $this->assertEquals(50, $testOutput['freePercentage']);
28
    }
29
30
    public function testMemcacheServerDown(): void
31
    {
32
        $testData = new TestData([
33
            'serverStats' => false,
34
            'host' => 'testhost.example.org',
35
        ]);
36
        $testCase = new TestCase\Store\Memcache\Server($testData);
37
38
        $testResult = $testCase->getTestResult();
39
        $this->assertEquals(State::ERROR, $testResult->getState());
40
    }
41
}
42