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

TestMemcacheServerTest::testMemcacheServerUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
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