2017-12-20 08:36:49 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace LibreNMS\Tests;
|
|
|
|
|
2019-10-13 13:40:38 +00:00
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
2018-05-09 06:53:45 -05:00
|
|
|
|
2019-10-13 13:40:38 +00:00
|
|
|
abstract class TestCase extends BaseTestCase
|
2017-12-20 08:36:49 -06:00
|
|
|
{
|
2019-10-13 13:40:38 +00:00
|
|
|
use CreatesApplication;
|
Refactored and update Location Geocoding (#9359)
- Fix location so it is a regular database relation (this allows multiple devices to be accurately linked to one location and saves api calls)
- Parse coordinates from the location more consistently
- Add settings to webui
- ~~Used [PHP Geocoder](http://geocoder-php.org/), which has lots of backends and is well tested. (also includes reverse and geoip)~~
- Google Maps, Bing, Mapquest, and OpenStreetMap supported initially.
- Default to OpenStreetMap, which doesn't require a key. They will liberally hand out bans if you exceed 1 query per second though.
- All other Geocoding APIs require an API key. (Google requires a credit card on file, but seems to be the most accurate)
- Update all (I think) sql queries to handle the new structure
- Remove final vestiges of override_sysLocation as a device attribute
- Update existing device groups and rules in DB
- Tested all APIs with good/bad location, no/bad/good key, and no connection.
- Cannot fix advanced queries that use location
This blocks #8868
DO NOT DELETE THIS TEXT
#### Please note
> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.
- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)
#### Testers
If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert.
2018-11-28 16:49:18 -06:00
|
|
|
use SnmpsimHelpers;
|
|
|
|
|
2018-05-09 06:53:45 -05:00
|
|
|
public function __construct($name = null, $data = [], $dataName = '')
|
|
|
|
{
|
|
|
|
parent::__construct($name, $data, $dataName);
|
|
|
|
// grab global $snmpsim from bootstrap and make it accessible
|
2019-10-13 13:40:38 +00:00
|
|
|
$this->getSnmpsim();
|
2019-03-12 23:59:03 -05:00
|
|
|
}
|
|
|
|
|
2017-12-20 08:36:49 -06:00
|
|
|
public function dbSetUp()
|
|
|
|
{
|
|
|
|
if (getenv('DBTEST')) {
|
2018-08-17 15:29:20 -05:00
|
|
|
\LibreNMS\DB\Eloquent::DB()->beginTransaction();
|
2017-12-20 08:36:49 -06:00
|
|
|
} else {
|
|
|
|
$this->markTestSkipped('Database tests not enabled. Set DBTEST=1 to enable.');
|
|
|
|
}
|
|
|
|
}
|
2020-09-21 14:54:51 +02:00
|
|
|
|
2017-12-20 08:36:49 -06:00
|
|
|
public function dbTearDown()
|
|
|
|
{
|
|
|
|
if (getenv('DBTEST')) {
|
2019-10-13 13:40:38 +00:00
|
|
|
try {
|
|
|
|
\LibreNMS\DB\Eloquent::DB()->rollBack();
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$this->fail("Exception when rolling back transaction.\n" . $e->getTraceAsString());
|
|
|
|
}
|
2017-12-20 08:36:49 -06:00
|
|
|
}
|
|
|
|
}
|
2022-07-20 08:27:57 -05:00
|
|
|
|
|
|
|
protected function tearDown(): void
|
|
|
|
{
|
|
|
|
$this->beforeApplicationDestroyed(function () {
|
|
|
|
$this->getConnection()->disconnect();
|
|
|
|
});
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
2017-12-20 08:36:49 -06:00
|
|
|
}
|