Passed
Branch monitor-2.5.x (1a1f16)
by Tim
03:17
created

TestMetadataExpirationTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testMetadataValid() 0 10 1
A testMetadataNeverExpires() 0 10 1
A testMetadataExpired() 0 10 1
1
<?php
2
3
namespace SimpleSAML\Modules\Monitor\Test;
4
5
use \SimpleSAML\Modules\Monitor\TestCase as TestCase;
6
use \SimpleSAML\Modules\Monitor\TestData as TestData;
7
use \SimpleSAML\Modules\Monitor\State as State;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\Modules\Monitor\State was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Tests for TestCase\Metadata\Expiration
11
 */
12
class TestMetadataExpirationTest extends \PHPUnit_Framework_TestCase
13
{
14
    public function testMetadataExpired()
15
    {
16
        $testData = new TestData([
17
            'entityId' => 'https://example.org',
18
            'entityMetadata' => ['expire' => time() - 1000],
19
        ]);
20
        $expirationTest = new TestCase\Metadata\Expiration($testData);
21
        $testResult = $expirationTest->getTestResult();
22
23
        $this->assertEquals(State::ERROR, $testResult->getState());
24
    }
25
26
    public function testMetadataValid()
27
    {
28
        $testData = new TestData([
29
            'entityId' => 'https://example.org',
30
            'entityMetadata' => ['expire' => time() + 1000],
31
        ]);
32
        $expirationTest = new TestCase\Metadata\Expiration($testData);
33
        $testResult = $expirationTest->getTestResult();
34
35
        $this->assertEquals(State::OK, $testResult->getState());
36
    }
37
38
    public function testMetadataNeverExpires()
39
    {
40
        $testData = new TestData([
41
            'entityId' => 'https://example.org',
42
            'entityMetadata' => [],
43
        ]);
44
        $expirationTest = new TestCase\Metadata\Expiration($testData);
45
        $testResult = $expirationTest->getTestResult();
46
47
        $this->assertEquals(State::OK, $testResult->getState());
48
    }
49
}
50