- $oDB = null;
- $oStatus = new Status($oDB);
- $this->assertEquals('No database', $oStatus->status());
- }
-
-
- public function testModuleFail()
- {
- $this->setExpectedException(Exception::class, 'Module call failed', 702);
-
- // stub has getOne method but doesn't return anything
- $oDbStub = $this->getMock(\DB::class, array('getOne'));
-
- $oStatus = new Status($oDbStub);
- $this->assertNull($oStatus->status());
- }
-
-
- public function testWordIdQueryFail()
- {
- $this->setExpectedException(Exception::class, 'No value', 704);
-
- $oDbStub = $this->getMock(\DB::class, array('getOne'));
-
- // return no word_id
- $oDbStub->method('getOne')
- ->will($this->returnCallback(function ($sql) {
- if (preg_match("/make_standard_name\('a'\)/", $sql)) return 'a';
- if (preg_match('/SELECT word_id, word_token/', $sql)) return null;
+ $oDbStub->method('connect')
+ ->will($this->returnCallback(function () {
+ throw new \Nominatim\DatabaseError('psql connection problem', 500, null, 'unknown database');