Passed
Push — master ( 314db7...711d5f )
by Tim
01:42
created

TestMemcacheServerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
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 as TestCase;
6
use \SimpleSAML\Module\monitor\TestData as TestData;
7
use \SimpleSAML\Module\monitor\TestResult as TestResult;
8
use \SimpleSAML\Module\monitor\State as State;
9
10
/**
11
 * Tests for MemcacheServer
12
 */
13
class TestMemcacheServerTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testMemcacheServerUp()
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()
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