Skip to content

Commit

Permalink
Use in-memory sqlite DB for integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
alariva committed Sep 15, 2018
1 parent 01d7bcd commit 1a86eed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"homepage": "https://github.com/alariva/laravel-modelmerge",
"keywords": ["Laravel", "ModelMerge"],
"require": {
"illuminate/support": "~5"
"illuminate/support": "~5",
"illuminate/database": "~5"
},
"require-dev": {
"phpunit/phpunit": "~6.0",
Expand Down
29 changes: 29 additions & 0 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,39 @@
namespace Tests;

use Alariva\ModelMerge\ModelMergeServiceProvider;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
use Orchestra\Testbench\TestCase as OrchestraTestCase;

abstract class BaseTestCase extends OrchestraTestCase
{

protected function setUp()
{
parent::setUp();

$capsule = new Capsule;

$capsule->addConnection([
'driver' => 'sqlite',
'database' => ':memory:'
]);

$capsule->setAsGlobal();
$capsule->bootEloquent();

Capsule::schema()->create('dummy_contacts', function (Blueprint $table) {
$table->increments('id');
$table->string('firstname');
$table->string('lastname');
$table->string('age')->nullable();
$table->string('eyes')->nullable();
$table->string('phone')->nullable();
$table->string('address')->nullable();
$table->timestamps();
});
}

/**
* Load package service provider
*
Expand Down
12 changes: 0 additions & 12 deletions tests/DummyContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,4 @@ class DummyContact extends Model
protected $hidden = ['id'];

protected $dates = ['created_at', 'deleted_at'];

public function save(array $options = [])
{
$this->exists = true;
$this->wasRecentlyCreated = true;
}

public function delete()
{
$this->exists = false;
$this->wasRecentlyCreated = false;
}
}

0 comments on commit 1a86eed

Please sign in to comment.