tests and laravel models
This commit is contained in:
53
tests/unit/Laravel5/BaseDbTest.php
Normal file
53
tests/unit/Laravel5/BaseDbTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace Tests\Laravel5;
|
||||
|
||||
use Codeception\TestCase\Test;
|
||||
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
|
||||
use XaiCorp\AbcParser\Models\Laravel5\Abc;
|
||||
|
||||
class BaseDbTest extends Test
|
||||
{
|
||||
use TestHelperTrait;
|
||||
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* Define environment setup.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
protected function getEnvironmentSetUp($app)
|
||||
{
|
||||
// Setup default database to use sqlite :memory:
|
||||
$app['config']->set('database.default', 'testbench');
|
||||
$app['config']->set('database.connections.testbench', [
|
||||
'driver' => 'sqlite',
|
||||
'database' => ':memory:',
|
||||
'prefix' => '',
|
||||
]);
|
||||
$app->setBasePath(dirname(dirname(dirname(__DIR__))));
|
||||
$Artisan = $app->make('Artisan');
|
||||
$Artisan::call('migrate');
|
||||
}
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->startApplication();
|
||||
$db = app()->make('db');
|
||||
$db->beginTransaction();
|
||||
|
||||
$this->withFactories(__DIR__ . '/factories');
|
||||
$this->builder = new Abc();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
$db = app()->make('db');
|
||||
$db->rollBack();
|
||||
$this->stopApplication();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user