createOne(); $this->assertIsString($audio->getName()); }); test('has subtitle', function () { $audio = Audio::factory()->createOne(); $this->assertIsString($audio->getSubtitle()); }); test('videos', function () { $videoCount = fake()->randomDigitNotNull(); $audio = Audio::factory() ->has(Video::factory()->count($videoCount)) ->createOne(); $this->assertInstanceOf(HasMany::class, $audio->videos()); $this->assertEquals($videoCount, $audio->videos()->count()); $this->assertInstanceOf(Video::class, $audio->videos()->first()); }); test('audio storage deletion', function () { $fs = Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); $file = File::fake()->create(fake()->word().'.ogg', fake()->randomDigitNotNull()); $fsFile = $fs->putFile('', $file); $audio = Audio::factory()->createOne([ Audio::ATTRIBUTE_PATH => $fsFile, ]); $audio->delete(); $this->assertTrue($fs->exists($audio->path)); }); test('audio storage force deletion', function () { Event::fakeExcept(AudioForceDeleting::class); $fs = Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); $file = File::fake()->create(fake()->word().'.ogg', fake()->randomDigitNotNull()); $fsFile = $fs->putFile('', $file); $audio = Audio::factory()->createOne([ Audio::ATTRIBUTE_PATH => $fsFile, ]); $audio->forceDelete(); $this->assertFalse($fs->exists($audio->path)); });