. * * @link https://www.librenms.org * @copyright 2020 Tony Murray * @author Tony Murray */ namespace LibreNMS\Tests\Unit; use Artisan; use Illuminate\Database\QueryException; use LibreNMS\Tests\TestCase; class SqliteTest extends TestCase { private $connection = 'testing_memory'; public function testMigrationsRunWithoutError() { try { $result = Artisan::call('migrate', ['--database' => $this->connection, '--seed' => true]); $output = Artisan::output(); $this->assertEquals(0, $result, "SQLite migration failed:\n$output"); $this->assertNotEmpty($output, 'Migrations not run'); } catch (QueryException $queryException) { preg_match('/Migrating: (\w+)$/', Artisan::output(), $matches); $migration = $matches[1] ?? '?'; $output = isset($matches[1]) ? '' : "\n\n" . Artisan::output(); $this->fail($queryException->getMessage() . $output . "\n\nCould not run migration {$migration}) on SQLite"); } $count = \DB::connection($this->connection)->table('alert_templates')->count(); $this->assertGreaterThan(0, $count, 'Database content check failed.'); } }