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
|
|
|
private $dependencies = false; |
14
|
|
|
|
15
|
|
|
// This whole class relies on \SimpleSAML_Configuration::setPreLoadedConfig(), which is not available until after 1.15.4 |
16
|
|
|
protected function testDependencies() |
17
|
|
|
{ if (method_exists('SimpleSAML_Configuration', 'setPreLoadedConfig')) { |
18
|
|
|
$this->dependencies = true; |
19
|
|
|
} |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testSqlSuccess() |
23
|
|
|
{ |
24
|
|
|
if ($this->dependencies === false) { |
25
|
|
|
$this->markTestSkipped('Precondition not met'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$globalConfig_input = [ |
29
|
|
|
'store.type' => 'sql', |
30
|
|
|
'store.sql.dsn' => 'sqlite:/modules/monitor/tests/files/test.sqlite', |
31
|
|
|
'store.sql.username' => 'test', |
32
|
|
|
'store.sql.password' => 'test', |
33
|
|
|
'store.sql.options' => null, |
34
|
|
|
'store.sql.prefix' => 'test' |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
$globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input); |
38
|
|
|
\SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php'); |
|
|
|
|
39
|
|
|
|
40
|
|
|
$testResult = $test->getTestResult(); |
|
|
|
|
41
|
|
|
$this->assertEquals(State::OK, $testResult->getState()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testSqlFailure() |
45
|
|
|
{ |
46
|
|
|
if ($this->dependencies === false) { |
47
|
|
|
$this->markTestSkipped('Precondition not met'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$globalConfig_input = [ |
51
|
|
|
'store.type' => 'sql', |
52
|
|
|
'store.sql.dsn' => '', |
53
|
|
|
'store.sql.username' => '', |
54
|
|
|
'store.sql.password' => '', |
55
|
|
|
'store.sql.options' => null, |
56
|
|
|
'store.sql.prefix' => 'test' |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
$globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input); |
60
|
|
|
\SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php'); |
61
|
|
|
|
62
|
|
|
$test = new Sql(); |
|
|
|
|
63
|
|
|
$testResult = $test->getTestResult(); |
64
|
|
|
$this->assertEquals(State::FATAL, $testResult->getState()); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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.