From f7c8f9d7bda2f2cf9ed468f3bf950a04355f443f Mon Sep 17 00:00:00 2001 From: ChristopherHicks Date: Wed, 26 Jun 2019 10:40:55 -0500 Subject: [PATCH 1/2] Fix the mockEvents for the contract --- tests/FunctionalTest.php | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 0f87acd..7b6bdd1 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -17,11 +17,13 @@ use Mockery as m; use VirtualFileSystem\FileSystem as Vfs; -class FunctionalTest extends PHPUnit_Framework_TestCase { +class FunctionalTest extends PHPUnit_Framework_TestCase +{ private $article; - protected function initUpchuck() { + protected function initUpchuck() + { // Setup filesystem $fs = new Vfs; @@ -48,22 +50,24 @@ protected function initUpchuck() { ); } - protected function mockEvents() { - return m::mock('Illuminate\Events\Dispatcher', [ 'dispatch' => null ]); + 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(); @@ -71,7 +75,8 @@ protected function setUpDatabase() { } // 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->increments('id'); $table->string('title'); @@ -113,7 +118,8 @@ protected function migrateTables($connection = 'default') { }); } - protected function seed() { + protected function seed() + { Article::unguard(); $this->article = Article::create([ 'title' => 'Test', @@ -141,7 +147,8 @@ protected function seed() { } // Test that a record is created in the same database - function testExists() { + function testExists() + { $this->initUpchuck(); $this->setUpDatabase(); $this->migrateTables(); @@ -205,7 +212,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(); @@ -227,7 +235,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 From 2088b6c0b5bbdddb889197d6a619e63d454f6367 Mon Sep 17 00:00:00 2001 From: ChristopherHicks Date: Thu, 27 Jun 2019 10:58:03 -0500 Subject: [PATCH 2/2] Workaround for the CI error for mockEvents --- tests/FunctionalTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 7b6bdd1..8a9ef83 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -50,6 +50,9 @@ protected function initUpchuck() ); } + /** + * @return mixed + */ protected function mockEvents() { return m::mock('Illuminate\Contracts\Events\Dispatcher', ['dispatch' => null]);