Level 102
You have () after $this
$this->
1 like
showing this error and first test is passing true why error :(
$ pf ProjectsTest
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.
.EE 3 / 3 (100%)
Time: 00:00.886, Memory: 32.00 MB
There were 2 errors:
1) Tests\Feature\ProjectsTest::test_a_project_requires_a_title
Error: Object of type Tests\Feature\ProjectsTest is not callable
C:\laragon\www\birdboard-tdd\tests\Feature\ProjectsTest.php:34
2) Tests\Feature\ProjectsTest::test_a_project_requires_a_description
Error: Object of type Tests\Feature\ProjectsTest is not callable
C:\laragon\www\birdboard-tdd\tests\Feature\ProjectsTest.php:39
my test code
public function test_a_user_can_create_a_project()
{
$this->withoutExceptionHandling();
$attributes = [
'title' => $this->faker->sentence,
'description' => $this->faker->sentence,
];
$this->post('/projects', $attributes)->assertRedirect('/projects');
$this->assertDatabaseHas('projects',$attributes);
$this->get('/projects')->assertSee($attributes['title']);
}
public function test_a_project_requires_a_title()
{
$this()->post('/projects', [])->assertSessionHasErrors('title');
}
public function test_a_project_requires_a_description()
{
$this()->post('/projects', [])->assertSessionHasErrors('description');
}
my controller code
public function store()
{
request()->validate([
'title' => 'required',
'description' => 'required'
]);
Project::create(request(['title', 'description']));
return redirect('/projects');
}
You have () after $this
$this->
Please or to participate in this conversation.