diff --git a/tests/APIs/WebinarListForUserTest.php b/tests/APIs/WebinarListForUserTest.php index 13f75fc..e77c84e 100644 --- a/tests/APIs/WebinarListForUserTest.php +++ b/tests/APIs/WebinarListForUserTest.php @@ -6,6 +6,8 @@ use EscolaLms\Webinar\Models\User; use EscolaLms\Webinar\Database\Seeders\WebinarsPermissionSeeder; use EscolaLms\Webinar\Models\Webinar; +use EscolaLms\Webinar\Services\Contracts\WebinarServiceContract; +use EscolaLms\Webinar\Services\WebinarService; use EscolaLms\Webinar\Tests\TestCase; use EscolaLms\Youtube\Services\Contracts\YoutubeServiceContract; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -23,6 +25,13 @@ protected function setUp(): void parent::setUp(); $this->seed(WebinarsPermissionSeeder::class); + $youtubeServiceContract = $this->mock(YoutubeServiceContract::class); + $youtubeServiceContract->shouldReceive('isConfigured')->zeroOrMoreTimes()->andReturn(true)->byDefault(); + $youtubeServiceContract->shouldReceive('getYtLiveStream')->zeroOrMoreTimes()->andReturn(collect([1]))->byDefault(); + + $this->app->forgetInstance(WebinarServiceContract::class); + $this->app->forgetInstance(WebinarService::class); + $this->user = User::factory()->create(); $this->user->guard_name = 'api'; $this->user->assignRole('tutor'); @@ -42,9 +51,6 @@ private function initVariable(): void public function testWebinarListForUser(): void { - $youtubeServiceContract = $this->mock(YoutubeServiceContract::class); - $youtubeServiceContract->shouldReceive('isConfigured')->zeroOrMoreTimes()->andReturn(true); - $youtubeServiceContract->shouldReceive('getYtLiveStream')->zeroOrMoreTimes()->andReturn(collect([1])); $this->initVariable(); $this->response = $this->actingAs($this->user, 'api')->json('GET', $this->apiUrl); $consArray = $this->webinars->pluck('id')->toArray(); @@ -91,10 +97,6 @@ public function durationProvider(): array */ public function testWebinarListOnlyIncoming(string $duration): void { - $youtubeServiceContract = $this->mock(YoutubeServiceContract::class); - $youtubeServiceContract->shouldReceive('isConfigured')->zeroOrMoreTimes()->andReturn(true); - $youtubeServiceContract->shouldReceive('getYtLiveStream')->zeroOrMoreTimes()->andReturn(collect([1])); - $student = User::factory()->create(); $student->guard_name = 'api'; $student->assignRole('student');