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

TestLdapConfigurationTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 20
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testLdapConfiguration() 0 31 1
1
<?php
2
3
namespace SimpleSAML\Module\Monitor\Test;
4
5
use SimpleSAML\Configuration;
6
use SimpleSAML\Module\Monitor\TestCase;
7
use SimpleSAML\Module\Monitor\TestData;
8
9
/**
10
 * Tests for TestCase\Ldap\Configuration
11
 */
12
class TestLdapConfigurationTest extends \PHPUnit\Framework\TestCase
13
{
14
    public function testLdapConfiguration(): void
15
    {
16
        $authSourceData = [
17
            'hostname' => 'ldaps://ldap.example.com:636',
18
            'debug' => false,
19
        ];
20
21
        $confTest = new TestCase\AuthSource\Ldap\Configuration(
22
            new TestData([
23
                'authSourceData' => Configuration::loadFromArray($authSourceData),
24
            ])
25
        );
26
27
        $testResult = $confTest->getTestResult();
28
        $this->assertEquals('ldaps://ldap.example.com:636', $testResult->getSubject());
29
30
        $authSourceData = [
31
            'hostname' => 'ldap.example.com',
32
            'port' => 636,
33
            'enable_tls' => true,
34
            'timeout' => 999,
35
            'debug' => false,
36
            'referrals' => true,
37
        ];
38
39
        $confTest = new TestCase\AuthSource\Ldap\Configuration(
40
            new TestData(['authSourceData' => Configuration::loadFromArray($authSourceData)])
41
        );
42
43
        $testResult = $confTest->getTestResult();
44
        $this->assertEquals('ldap.example.com:636', $testResult->getSubject());
45
    }
46
}
47