mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Test PHP 8.1 Would love to remove the PHP7 versions, but we need to update our minimum version first. * Try mariadb 10.8 * Reduce the number of open connections during testing.
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace LibreNMS\Tests;
|
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
use CreatesApplication;
|
|
use SnmpsimHelpers;
|
|
|
|
public function __construct($name = null, $data = [], $dataName = '')
|
|
{
|
|
parent::__construct($name, $data, $dataName);
|
|
// grab global $snmpsim from bootstrap and make it accessible
|
|
$this->getSnmpsim();
|
|
}
|
|
|
|
public function dbSetUp()
|
|
{
|
|
if (getenv('DBTEST')) {
|
|
\LibreNMS\DB\Eloquent::DB()->beginTransaction();
|
|
} else {
|
|
$this->markTestSkipped('Database tests not enabled. Set DBTEST=1 to enable.');
|
|
}
|
|
}
|
|
|
|
public function dbTearDown()
|
|
{
|
|
if (getenv('DBTEST')) {
|
|
try {
|
|
\LibreNMS\DB\Eloquent::DB()->rollBack();
|
|
} catch (\Exception $e) {
|
|
$this->fail("Exception when rolling back transaction.\n" . $e->getTraceAsString());
|
|
}
|
|
}
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
$this->beforeApplicationDestroyed(function () {
|
|
$this->getConnection()->disconnect();
|
|
});
|
|
|
|
parent::tearDown();
|
|
}
|
|
}
|