X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/890d415e1ffd997d11ed35dee04cb01b94ca133f..200eae3bc0b559e7df7c1d1fb50141830c2f1849:/test/php/Nominatim/StatusTest.php diff --git a/test/php/Nominatim/StatusTest.php b/test/php/Nominatim/StatusTest.php index f45e6633..5f8bac64 100644 --- a/test/php/Nominatim/StatusTest.php +++ b/test/php/Nominatim/StatusTest.php @@ -1,9 +1,19 @@ assertEquals('No database', $oStatus->status()); } - - public function testModuleFail() - { - $this->expectException(\Exception::class); - $this->expectExceptionMessage('Module call failed'); - $this->expectExceptionCode(702); - - // stub has getOne method but doesn't return anything - $oDbStub = $this->getMockBuilder(Nominatim\DB::class) - ->setMethods(array('connect', 'getOne')) - ->getMock(); - - $oStatus = new Status($oDbStub); - $this->assertNull($oStatus->status()); - } - - - public function testWordIdQueryFail() - { - $this->expectException(\Exception::class); - $this->expectExceptionMessage('No value'); - $this->expectExceptionCode(704); - - $oDbStub = $this->getMockBuilder(Nominatim\DB::class) - ->setMethods(array('connect', 'getOne')) - ->getMock(); - - // 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; - })); - - $oStatus = new Status($oDbStub); - $this->assertNull($oStatus->status()); - } - - public function testOK() { $oDbStub = $this->getMockBuilder(Nominatim\DB::class) @@ -100,7 +71,7 @@ class StatusTest extends \PHPUnit\Framework\TestCase $oDbStub = $this->getMockBuilder(Nominatim\DB::class) ->setMethods(array('getOne')) ->getMock(); - + $oDbStub->method('getOne') ->willReturn(1519430221);