create(fake()->word().'.webm', fake()->randomDigitNotNull()); Process::fake([ UploadedFileAction::formatLoudnessCommand($file) => Process::result(errorOutput: json_encode([ 'input_i' => fake()->randomFloat(), 'input_tp' => fake()->randomFloat(), 'input_lra' => fake()->randomFloat(), 'input_thresh' => fake()->randomFloat(), 'output_i' => fake()->randomFloat(), 'output_tp' => fake()->randomFloat(), 'output_lra' => fake()->randomFloat(), 'output_thresh' => fake()->randomFloat(), 'normalization_type' => 'dynamic', 'target_offset' => fake()->randomFloat(), ])), UploadedFileAction::formatFfprobeCommand($file) => Process::result(json_encode([ 'streams' => [ 0 => [ 'codec_type' => 'video', 'pix_fmt' => fake()->randomDigitNot(2), ], ], ])), ]); $validator = Validator::make( ['file' => $file], ['file' => new VideoPixelFormatStreamRule()], ); $this->assertFalse($validator->passes()); Process::assertRan(UploadedFileAction::formatFfprobeCommand($file)); }); test('passes when codec is yuv420p', function () { Feature::activate(FeatureConstants::VIDEO_PIXEL_FORMAT_STREAM, 'yuv420p'); $file = UploadedFile::fake()->create(fake()->word().'.webm', fake()->randomDigitNotNull()); Process::fake([ UploadedFileAction::formatLoudnessCommand($file) => Process::result(errorOutput: json_encode([ 'input_i' => fake()->randomFloat(), 'input_tp' => fake()->randomFloat(), 'input_lra' => fake()->randomFloat(), 'input_thresh' => fake()->randomFloat(), 'output_i' => fake()->randomFloat(), 'output_tp' => fake()->randomFloat(), 'output_lra' => fake()->randomFloat(), 'output_thresh' => fake()->randomFloat(), 'normalization_type' => 'dynamic', 'target_offset' => fake()->randomFloat(), ])), UploadedFileAction::formatFfprobeCommand($file) => Process::result(json_encode([ 'streams' => [ 0 => [ 'codec_type' => 'video', 'pix_fmt' => 'yuv420p', ], ], ])), ]); $validator = Validator::make( ['file' => $file], ['file' => new VideoPixelFormatStreamRule()], ); $this->assertTrue($validator->passes()); Process::assertRan(UploadedFileAction::formatFfprobeCommand($file)); });