1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor\Test; |
4
|
|
|
|
5
|
|
|
use \SimpleSAML\Module\monitor\TestCase\Store\Sql as Sql; |
6
|
|
|
use \SimpleSAML\Module\monitor\State as State; |
7
|
|
|
|
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'); |
|
|
|
|
28
|
|
|
|
29
|
|
|
$test = new Sql($globalConfig); |
|
|
|
|
30
|
|
|
$testResult = $test->getTestResult(); |
31
|
|
|
$this->assertEquals(State::OK, $testResult->getState()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testSqlFailure() |
35
|
|
|
{ |
36
|
|
|
$globalConfig_input = [ |
37
|
|
|
'store.type' => 'sql', |
38
|
|
|
'store.sql.dsn' => '', |
39
|
|
|
'store.sql.username' => '', |
40
|
|
|
'store.sql.password' => '', |
41
|
|
|
'store.sql.options' => null, |
42
|
|
|
'store.sql.prefix' => 'test' |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
$globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input); |
46
|
|
|
\SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php'); |
47
|
|
|
|
48
|
|
|
$test = new Sql($globalConfig); |
|
|
|
|
49
|
|
|
$testResult = $test->getTestResult(); |
50
|
|
|
$this->assertEquals(State::FATAL, $testResult->getState()); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
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.