Skip to content

Instantly share code, notes, and snippets.

@tonyfrenzy
Created June 13, 2020 20:10
Show Gist options
  • Save tonyfrenzy/99b5975d2f8d91253608a3cbfc80a348 to your computer and use it in GitHub Desktop.
Save tonyfrenzy/99b5975d2f8d91253608a3cbfc80a348 to your computer and use it in GitHub Desktop.
morphToMany() Many-to-Many Polymorphic Relationship Test (Video-tag) - Testing Model Relationships in Laravel
<?php
namespace Tests\Unit;
// ...
use App\Video;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
class VideosTest extends TestCase
{
use RefreshDatabase, WithFaker;
...
/** @test */
public function a_video_morphs_many_tags()
{
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $this->video->tags);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment