create($this->faker->word().'.webm', $this->faker->randomDigitNotNull()); Process::fake([ SubmissionRule::formatLoudnessCommand($file) => Process::result(errorOutput: json_encode([ 'input_i' => $this->faker->randomFloat(), 'input_tp' => $this->faker->randomFloat(), 'input_lra' => $this->faker->randomFloat(), 'input_thresh' => $this->faker->randomFloat(), 'output_i' => $this->faker->randomFloat(), 'output_tp' => $this->faker->randomFloat(), 'output_lra' => $this->faker->randomFloat(), 'output_thresh' => $this->faker->randomFloat(), 'normalization_type' => 'dynamic', 'target_offset' => $this->faker->randomFloat(), ])), SubmissionRule::formatFfprobeCommand($file) => Process::result(json_encode([ 'format' => [ 'bit_rate' => $this->faker->numberBetween(0, 127999), ], ])), ]); $validator = Validator::make( ['file' => $file], ['file' => new AudioBitrateRestrictionFormatRule()], ); static::assertFalse($validator->passes()); Process::assertRan(SubmissionRule::formatFfprobeCommand($file)); } /** * The Audio Bitrate Restriction Format Rule shall fail if the audio bitrate is within the accepted boundaries. * * @return void */ public function testPassesWhenBitrateIsExpected(): void { Feature::activate(FeatureConstants::AUDIO_BITRATE_RESTRICTION); $file = UploadedFile::fake()->create($this->faker->word().'.webm', $this->faker->randomDigitNotNull()); Process::fake([ SubmissionRule::formatLoudnessCommand($file) => Process::result(errorOutput: json_encode([ 'input_i' => $this->faker->randomFloat(), 'input_tp' => $this->faker->randomFloat(), 'input_lra' => $this->faker->randomFloat(), 'input_thresh' => $this->faker->randomFloat(), 'output_i' => $this->faker->randomFloat(), 'output_tp' => $this->faker->randomFloat(), 'output_lra' => $this->faker->randomFloat(), 'output_thresh' => $this->faker->randomFloat(), 'normalization_type' => 'dynamic', 'target_offset' => $this->faker->randomFloat(), ])), SubmissionRule::formatFfprobeCommand($file) => Process::result(json_encode([ 'format' => [ 'bit_rate' => $this->faker->numberBetween(128001, 359999), ], ])), ]); $validator = Validator::make( ['file' => $file], ['file' => new AudioBitrateRestrictionFormatRule()], ); static::assertTrue($validator->passes()); Process::assertRan(SubmissionRule::formatFfprobeCommand($file)); } }