Files
librenms-librenms/tests/TestCase.php
T

39 lines
1006 B
PHP
Raw Normal View History

<?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
{
2019-10-13 13:40:38 +00:00
use CreatesApplication;
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
}
public function dbSetUp()
{
if (getenv('DBTEST')) {
2018-08-17 15:29:20 -05:00
\LibreNMS\DB\Eloquent::DB()->beginTransaction();
} else {
$this->markTestSkipped('Database tests not enabled. Set DBTEST=1 to enable.');
}
}
2020-09-21 14:54:51 +02: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());
}
}
}
}