From 44aa6e830882eef0871f050908e69fa45909034e Mon Sep 17 00:00:00 2001 From: Anton Komarev <1849174+antonkomarev@users.noreply.github.com> Date: Thu, 30 Jan 2020 09:20:46 +0300 Subject: [PATCH] Replace EntityWithMorphMap with MorphMappedReactable stub (#135) --- tests/Stubs/Models/EntityWithMorphMap.php | 40 ------------------- tests/TestCase.php | 2 - tests/Unit/Console/Commands/RecountTest.php | 26 ++++++------ .../database/factories/EntityWithMorphMap.php | 22 ---------- 4 files changed, 13 insertions(+), 77 deletions(-) delete mode 100644 tests/Stubs/Models/EntityWithMorphMap.php delete mode 100644 tests/database/factories/EntityWithMorphMap.php diff --git a/tests/Stubs/Models/EntityWithMorphMap.php b/tests/Stubs/Models/EntityWithMorphMap.php deleted file mode 100644 index 6e2bf685..00000000 --- a/tests/Stubs/Models/EntityWithMorphMap.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Cog\Tests\Laravel\Love\Stubs\Models; - -use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract; -use Cog\Laravel\Love\Reactable\Models\Traits\Reactable; -use Illuminate\Database\Eloquent\Model; - -final class EntityWithMorphMap extends Model implements - ReactableContract -{ - use Reactable; - - /** - * The table associated with the model. - * - * @var string - */ - protected $table = 'entities_with_morph_map'; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = [ - 'name', - ]; -} diff --git a/tests/TestCase.php b/tests/TestCase.php index a7e8dc08..e1f48657 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,7 +14,6 @@ namespace Cog\Tests\Laravel\Love; use Cog\Laravel\Love\LoveServiceProvider; -use Cog\Tests\Laravel\Love\Stubs\Models\EntityWithMorphMap; use Cog\Tests\Laravel\Love\Stubs\Models\MorphMappedReactable; use Cog\Tests\Laravel\Love\Stubs\Models\MorphMappedReacterable; use Cog\Tests\Laravel\Love\Stubs\Models\User; @@ -103,7 +102,6 @@ private function registerPackageFactories(): void private function registerTestMorphMaps(): void { Relation::morphMap([ - 'entity-with-morph-map' => EntityWithMorphMap::class, 'morph-mapped-reactable' => MorphMappedReactable::class, 'morph-mapped-reacterable' => MorphMappedReacterable::class, ]); diff --git a/tests/Unit/Console/Commands/RecountTest.php b/tests/Unit/Console/Commands/RecountTest.php index 1b83c84a..3e35c4b6 100644 --- a/tests/Unit/Console/Commands/RecountTest.php +++ b/tests/Unit/Console/Commands/RecountTest.php @@ -24,7 +24,7 @@ use Cog\Tests\Laravel\Love\Stubs\Models\Article; use Cog\Tests\Laravel\Love\Stubs\Models\Bot; use Cog\Tests\Laravel\Love\Stubs\Models\Entity; -use Cog\Tests\Laravel\Love\Stubs\Models\EntityWithMorphMap; +use Cog\Tests\Laravel\Love\Stubs\Models\MorphMappedReactable; use Cog\Tests\Laravel\Love\TestCase; final class RecountTest extends TestCase @@ -235,7 +235,7 @@ public function it_can_recount_reactions_of_one_reaction_type_for_one_reactable_ ReactionCounter::query()->truncate(); $status = $this->artisan('love:recount', [ - '--model' => 'entity-with-morph-map', + '--model' => 'morph-mapped-reactable', '--type' => 'Like', ]); @@ -278,7 +278,7 @@ public function it_can_recount_reactions_of_one_reaction_type_for_one_reactable_ ] = $this->seedTestData(); $status = $this->artisan('love:recount', [ - '--model' => 'entity-with-morph-map', + '--model' => 'morph-mapped-reactable', '--type' => 'Like', ]); @@ -322,7 +322,7 @@ public function it_can_recount_reactions_of_one_reaction_type_for_one_reactable_ ReactionCounter::query()->truncate(); $status = $this->artisan('love:recount', [ - '--model' => EntityWithMorphMap::class, + '--model' => MorphMappedReactable::class, '--type' => 'Like', ]); @@ -365,7 +365,7 @@ public function it_can_recount_reactions_of_one_reaction_type_for_one_reactable_ ] = $this->seedTestData(); $status = $this->artisan('love:recount', [ - '--model' => EntityWithMorphMap::class, + '--model' => MorphMappedReactable::class, '--type' => 'Like', ]); @@ -579,7 +579,7 @@ public function it_can_recount_reactions_of_any_reaction_type_for_one_reactable_ ReactionCounter::query()->truncate(); $status = $this->artisan('love:recount', [ - '--model' => 'entity-with-morph-map', + '--model' => 'morph-mapped-reactable', ]); $counters = ReactionCounter::query()->count(); @@ -622,7 +622,7 @@ public function it_can_recount_reactions_of_any_reaction_type_for_one_reactable_ ] = $this->seedTestData(); $status = $this->artisan('love:recount', [ - '--model' => 'entity-with-morph-map', + '--model' => 'morph-mapped-reactable', ]); $counters = ReactionCounter::query()->count(); @@ -666,7 +666,7 @@ public function it_can_recount_reactions_of_any_reaction_type_for_one_reactable_ ReactionCounter::query()->truncate(); $status = $this->artisan('love:recount', [ - '--model' => EntityWithMorphMap::class, + '--model' => MorphMappedReactable::class, ]); $counters = ReactionCounter::query()->count(); @@ -709,7 +709,7 @@ public function it_can_recount_reactions_of_any_reaction_type_for_one_reactable_ ] = $this->seedTestData(); $status = $this->artisan('love:recount', [ - '--model' => EntityWithMorphMap::class, + '--model' => MorphMappedReactable::class, ]); $counters = ReactionCounter::query()->count(); @@ -988,11 +988,11 @@ private function seedTestData(): array { $reactant1 = factory(Entity::class)->create() ->getLoveReactant(); - $reactant2 = factory(EntityWithMorphMap::class)->create() + $reactant2 = factory(MorphMappedReactable::class)->create() ->getLoveReactant(); $reactant3 = factory(Article::class)->create() ->getLoveReactant(); - $reactant4 = factory(EntityWithMorphMap::class)->create() + $reactant4 = factory(MorphMappedReactable::class)->create() ->getLoveReactant(); $reacter1 = factory(Reacter::class)->create(); @@ -1019,9 +1019,9 @@ private function seedTestData(): array return [ $reactant1, // 3 likes | 0 dislikes | Entity - $reactant2, // 2 likes | 1 dislikes | EntityWithMorphMap + $reactant2, // 2 likes | 1 dislikes | MorphMappedReactable $reactant3, // 2 likes | 2 dislikes | Article - $reactant4, // 1 likes | 2 dislikes | EntityWithMorphMap + $reactant4, // 1 likes | 2 dislikes | MorphMappedReactable ]; } } diff --git a/tests/database/factories/EntityWithMorphMap.php b/tests/database/factories/EntityWithMorphMap.php deleted file mode 100644 index 9dfc41c9..00000000 --- a/tests/database/factories/EntityWithMorphMap.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -use Cog\Tests\Laravel\Love\Stubs\Models\EntityWithMorphMap; -use Faker\Generator as Faker; - -/* @var \Illuminate\Database\Eloquent\Factory $factory */ -$factory->define(EntityWithMorphMap::class, function (Faker $faker) { - return [ - 'name' => $faker->name, - ]; -});