createOne(); $response = $this->get(route('video.show', ['video' => $video])); $response->assertForbidden(); } /** * If the video is soft-deleted, the user shall receive a forbidden exception. * * @return void */ public function testSoftDeleteVideoStreamingForbidden(): void { Config::set(FlagConstants::ALLOW_VIDEO_STREAMS_FLAG_QUALIFIED, true); $video = Video::factory()->createOne(); $video->delete(); $response = $this->get(route('video.show', ['video' => $video])); $response->assertForbidden(); } /** * If view recording is disabled, the video show route shall not record a view for the video. * * @return void */ public function testViewRecordingNotAllowed(): void { Config::set(FlagConstants::ALLOW_VIDEO_STREAMS_FLAG_QUALIFIED, true); Config::set(FlagConstants::ALLOW_VIEW_RECORDING_FLAG_QUALIFIED, false); $video = Video::factory()->createOne(); $this->get(route('video.show', ['video' => $video])); static::assertEquals(0, $video->views()->count()); } /** * If view recording is enabled, the video show route shall record a view for the video. * * @return void */ public function testViewRecordingIsAllowed(): void { Config::set(FlagConstants::ALLOW_VIDEO_STREAMS_FLAG_QUALIFIED, true); Config::set(FlagConstants::ALLOW_VIEW_RECORDING_FLAG_QUALIFIED, true); $video = Video::factory()->createOne(); $this->get(route('video.show', ['video' => $video])); static::assertEquals(1, $video->views()->count()); } /** * If view recording is enabled, the video show route shall record a view for the video. * * @return void */ public function testViewRecordingCooldown(): void { Config::set(FlagConstants::ALLOW_VIDEO_STREAMS_FLAG_QUALIFIED, true); Config::set(FlagConstants::ALLOW_VIEW_RECORDING_FLAG_QUALIFIED, true); $video = Video::factory()->createOne(); Collection::times($this->faker->randomDigitNotNull(), function () use ($video) { $this->get(route('video.show', ['video' => $video])); }); static::assertEquals(1, $video->views()->count()); } }