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