| Conditions | 4 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function invokeTest() |
||
| 36 | { |
||
| 37 | try { |
||
| 38 | $this->db = \SimpleSAML\Database::getInstance(); |
||
| 39 | } catch (\Exception $error) { |
||
| 40 | // Fallthru |
||
| 41 | } |
||
| 42 | |||
| 43 | $testResult = new TestResult('Database connection', $this->dsn); |
||
| 44 | |||
| 45 | if (isSet($error)) { |
||
| 46 | $testResult->setState(State::WARNING); |
||
| 47 | $testResult->setMessage($error->getMessage()); |
||
| 48 | } else if (!is_null($this->db)) { |
||
| 49 | $testResult->setState(State::OK); |
||
| 50 | $testResult->setMessage('Connection established'); |
||
| 51 | $testResult->addOutput($this->db, 'db'); |
||
| 52 | } else { // Shoud never happen |
||
| 53 | $testResult->setState(State::WARNING); |
||
| 54 | $testResult->setMessage("Something went wrong and we couldn't tell why"); |
||
| 55 | } |
||
| 56 | |||
| 57 | $this->setTestResult($testResult); |
||
| 58 | } |
||
| 60 |