Passed
Push — master ( 9792fc...04e5e0 )
by Tim
06:59
created

TestMemcacheServerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

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