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