Passed
Push — master ( e2d9db...8e5e23 )
by Tim
02:07
created

TestSqlTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSqlFailure() 0 16 1
A testSqlSuccess() 0 16 1
1
<?php
2
3
namespace SimpleSAML\Module\monitor\Test;
4
5
use \SimpleSAML\Module\monitor\Store\Sql as Sql;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\Module\monitor\Store\Sql 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...
6
7
// This test relies on \SimpleSAML_Configuration::setPreLoadedConfig(), which is not available until after 1.15.4
8
if (method_exists('SimpleSAML_Configuration', 'setPreLoadedConfig')) {
9
10
/**
11
 * Tests for Sql
12
 */
13
class TestSqlTest extends \SimpleSAML\Test\Utils\ClearStateTestCase
14
{
15
    public function testSqlSuccess()
16
    {
17
        $globalConfig_input = [
18
            'store.type' => 'sql',
19
            'store.sql.dsn' => 'sqlite:/modules/monitor/tests/files/test.sqlite',
20
            'store.sql.username' => 'test',
21
            'store.sql.password' => 'test',
22
            'store.sql.options' => null,
23
            'store.sql.prefix' => 'test'
24
        ];
25
26
        $globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input);
27
        \SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php');
0 ignored issues
show
Bug introduced by
The method setPreLoadedConfig() does not exist on SimpleSAML_Configuration. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        \SimpleSAML_Configuration::/** @scrutinizer ignore-call */ 
28
                                   setPreLoadedConfig($globalConfig, 'config.php');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
29
        $test = new Sql();
30
        $this->assertEquals(true, $test->pdo instanceof \PDO);
31
    }
32
33
    public function testSqlFailure()
34
    {
35
        $globalConfig_input = [
36
            'store.type' => 'sql',
37
            'store.sql.dsn' => '',
38
            'store.sql.username' => '',
39
            'store.sql.password' => '',
40
            'store.sql.options' => null,
41
            'store.sql.prefix' => 'test'
42
        ];
43
44
        $globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input);
45
        \SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php');
46
47
        $this->expectException(\Exception);
0 ignored issues
show
Bug introduced by
The constant Exception was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The method expectException() does not exist on SimpleSAML\Module\monitor\Test\TestSqlTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        $this->/** @scrutinizer ignore-call */ 
48
               expectException(\Exception);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
        new Sql();
49
    }
50
}
51
52
}
53