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
|
|
|
/** |
9
|
|
|
* Tests for Sql |
10
|
|
|
*/ |
11
|
|
|
class TestSqlTest extends \SimpleSAML\Test\Utils\ClearStateTestCase |
12
|
|
|
{ |
13
|
|
|
public function testBogus() |
14
|
|
|
{ |
15
|
|
|
$this->assertEquals(true, true); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testSqlSuccess() |
19
|
|
|
{ |
20
|
|
|
if (!method_exists('\SimpleSAML_Configuration', 'setPreLoadedConfig')) { |
21
|
|
|
$this->markTestIncomplete('A precondition was not met.'); |
22
|
|
|
} |
23
|
|
|
$globalConfig_input = [ |
24
|
|
|
'store.type' => 'sql', |
25
|
|
|
'store.sql.dsn' => 'sqlite:/modules/monitor/tests/files/test.sqlite', |
26
|
|
|
'store.sql.username' => 'test', |
27
|
|
|
'store.sql.password' => 'test', |
28
|
|
|
'store.sql.options' => null, |
29
|
|
|
'store.sql.prefix' => 'test' |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
$globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input); |
33
|
|
|
\SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php'); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$testResult = $test->getTestResult(); |
|
|
|
|
36
|
|
|
$this->assertEquals(State::OK, $testResult->getState()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testSqlFailure() |
40
|
|
|
{ |
41
|
|
|
if (!method_exists('\SimpleSAML_Configuration', 'setPreLoadedConfig')) { |
42
|
|
|
$this->markTestIncomplete('A precondition was not met.'); |
43
|
|
|
} |
44
|
|
|
$globalConfig_input = [ |
45
|
|
|
'store.type' => 'sql', |
46
|
|
|
'store.sql.dsn' => '', |
47
|
|
|
'store.sql.username' => '', |
48
|
|
|
'store.sql.password' => '', |
49
|
|
|
'store.sql.options' => null, |
50
|
|
|
'store.sql.prefix' => 'test' |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
$globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input); |
54
|
|
|
\SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php'); |
55
|
|
|
|
56
|
|
|
$test = new Sql(); |
|
|
|
|
57
|
|
|
$testResult = $test->getTestResult(); |
58
|
|
|
$this->assertEquals(State::FATAL, $testResult->getState()); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
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.