Seeing this exact thing myself and haven't figured out why! Also trying to follow along the Let's Build a Forum series while using Laravel 8.
Unknown formatter "paragraph" when unit testing
I was learning Let's Build A Forum with Laravel and TDD. There's an error occured when i do the unit test.
function it_has_an_owner(){
$reply = Reply::factory()->create();
$this->assertInstanceOf('App\Models\User', $reply->owner);
}
There was 1 error:
- Tests\Unit\ReplyTest::it_has_an_owner InvalidArgumentException: Unknown formatter "paragraph"
D:\work\laracasts_forum\vendor\fakerphp\faker\src\Faker\Generator.php:250 D:\work\laracasts_forum\vendor\fakerphp\faker\src\Faker\Generator.php:230 D:\work\laracasts_forum\vendor\fakerphp\faker\src\Faker\Generator.php:287 D:\work\laracasts_forum\database\factories\ReplyFactory.php:33 D:\work\laracasts_forum\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Factories\Factory.php:380 D:\work\laracasts_forum\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Factories\Factory.php:359 D:\work\laracasts_forum\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Factories\Factory.php:343 D:\work\laracasts_forum\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\GuardsAttributes.php:157 D:\work\laracasts_forum\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Factories\Factory.php:348 D:\work\laracasts_forum\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Factories\Factory.php:316 D:\work\laracasts_forum\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Factories\Factory.php:228 D:\work\laracasts_forum\tests\Unit\ReplyTest.php:15
And the Reply factor is:
class ReplyFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Reply::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'thread_id' => function(){
return Thread::factory()->create()->id;
},
'user_id' => function(){
return User::factory()->create()->id;
},
'body' => $this->faker->paragraph,
];
}
}
Why is this happening?
Please or to participate in this conversation.