function testNoDatabaseFound() { if (file_exists(TEST_GEOIP_PLUGIN_DATA_FILENAME)) { $this->markTestSkipped('Test could not be executed: ' . TEST_GEOIP_PLUGIN_DATA_FILENAME . ' could not be deleted.'); } $thrown = false; try { $reader = geoip_detect2_get_reader(); $this->assertSame(null, $reader, 'geoip_detect2_get_info_from_ip() : should have returned NULL because there is no database'); } catch (Exception $e) { $thrown = true; } if (!$thrown) { $this->fail('geoip_detect2_get_reader(): No database missing exception was thrown.'); } $thrown = false; try { $ret = geoip_detect2_get_info_from_ip(GEOIP_DETECT_TEST_IP, 'geoip_detect2_get_info_from_ip() : should have returned NULL because there is no database'); $this->assertSame(null, $ret); } catch (Exception $e) { $thrown = true; } if (!$thrown) { $this->fail('geoip_detect2_get_info_from_ip(): No database missing exception was thrown.'); } }
/** * @group external-http * @expectedException \GeoIp2\Exception\AuthenticationException */ function testNoPasswordManualLookup() { remove_filter('pre_option_geoip-detect-precision-user_secret', array($this, 'filter_set_user_secret'), 101); add_filter('pre_option_geoip-detect-precision-user_secret', array($this, 'filter_set_wrong_user_secret'), 102); $reader = geoip_detect2_get_reader(); $this->assertNotNull($reader); $reader->city(GEOIP_DETECT_TEST_IP); }