Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch authored Sep 20, 2019
2 parents 22ec3bd + 0f16b54 commit 58c41db
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
use VirtualFileSystem\FileSystem as Vfs;
use PHPUnit\Framework\TestCase;


class FunctionalTest extends TestCase {
class FunctionalTest extends TestCase
{

private $article;

protected function initUpchuck() {
protected function initUpchuck()
{

// Setup filesystem
$fs = new Vfs;
Expand All @@ -50,30 +51,36 @@ protected function initUpchuck() {
);
}

protected function mockEvents() {
return m::mock('Illuminate\Events\Dispatcher', [ 'dispatch' => null ]);
/**
* @return mixed
*/
protected function mockEvents()
{
return m::mock('Illuminate\Contracts\Events\Dispatcher', ['dispatch' => null]);
}

// https://github.com/laracasts/TestDummy/blob/master/tests/FactoryTest.php#L18
protected function setUpDatabase() {
protected function setUpDatabase()
{
$db = new DB;

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

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

$db->bootEloquent();
$db->setAsGlobal();
}

// https://github.com/laracasts/TestDummy/blob/master/tests/FactoryTest.php#L31
protected function migrateTables($connection = 'default') {
protected function migrateTables($connection = 'default')
{
DB::connection($connection)->getSchemaBuilder()->create('articles', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
Expand Down Expand Up @@ -115,7 +122,8 @@ protected function migrateTables($connection = 'default') {
});
}

protected function seed() {
protected function seed()
{
Article::unguard();
$this->article = Article::create([
'title' => 'Test',
Expand Down Expand Up @@ -143,7 +151,8 @@ protected function seed() {
}

// Test that a record is created in the same database
function testExists() {
function testExists()
{
$this->initUpchuck();
$this->setUpDatabase();
$this->migrateTables();
Expand Down Expand Up @@ -207,7 +216,8 @@ function testExists() {
// use eloquent because Laravel has issues with relationships on models in
// a different connection
// https://github.com/laravel/framework/issues/9355
function testExistsInAltDatabaseAndFilesystem() {
function testExistsInAltDatabaseAndFilesystem()
{
$this->initUpchuck();
$this->setUpDatabase();
$this->migrateTables();
Expand All @@ -229,7 +239,7 @@ function testExistsInAltDatabaseAndFilesystem() {
// Test that the new article was created
$this->assertEquals(1, DB::connection('alt')->table('articles')->count());
$clone = DB::connection('alt')->table('articles')->first();
$this->assertEquals(1 , $clone->id);
$this->assertEquals(1, $clone->id);
$this->assertEquals('Test', $clone->title);

// Test that many to many failed
Expand Down

0 comments on commit 58c41db

Please sign in to comment.