. * * @package LibreNMS * @link http://librenms.org * @copyright 2017 Tony Murray * @author Tony Murray */ namespace LibreNMS\Tests; use LibreNMS\Util\Snmpsim; abstract class TestCase extends \PHPUnit\Framework\TestCase { use SnmpsimHelpers; /** @var Snmpsim snmpsim instance */ protected $snmpsim = null; public function __construct($name = null, $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); // grab global $snmpsim from bootstrap and make it accessible global $snmpsim; $this->snmpsim = $snmpsim; } public function dbSetUp() { if (getenv('DBTEST')) { \LibreNMS\DB\Eloquent::boot(); \LibreNMS\DB\Eloquent::setStrictMode(); \LibreNMS\DB\Eloquent::DB()->beginTransaction(); } else { $this->markTestSkipped('Database tests not enabled. Set DBTEST=1 to enable.'); } } public function dbTearDown() { if (getenv('DBTEST')) { \LibreNMS\DB\Eloquent::DB()->rollBack(); } } }