Skip to main content

Registration to Activity

Premium
9 min read
Ali Al Qahtani avatar

aritsan need fix it to artisan in this line:

php aritsan make:test RegisterActivityTest

Luis Antonio Parrado avatar
Luis Antonio Parrado

@Povilas, test_guest_registers_to_activity() fails to send notification because User::find(1) is different to Test User. User #1 is a random user created by ActivityFactory, User #2 matches with Test User => test@test.com. So one way to fix this test would be to replace User::find(1) with User::find(2).

jerome borg avatar

hye or Notification::assertSentTo(User::where('email', 'test@test.com')->first(), RegisteredToActivityNotification::class);

teebee avatar

Thank you for this. It helped me to fix the last test.

Notification::assertSentTo(User::where('email', 'test@test.com')->first(), RegisteredToActivityNotification::class);

This instruction helped me. Using User::find(2) did not helped.

teebee avatar

Hi,

Test "test_shows_already_registered_when_user_is_registered_to_activity()" is failing with a large output, and the end message is:

View [activities.show] not found.
 
at tests\Feature\RegisterActivityTest.php:35
31
32 $response = $this->actingAs($user)->get(route('activity.show', $activity));
33
34 $response->assertSeeText('You have already registered.');
35 $response->assertDontSeeText('Register to Activity');
36 }
37
38 public function test_authenticated_user_can_register_to_activity()
39 {
 
 
Tests: 1 failed, 5 passed (17 assertions)
Duration: 2.71s

The odd thing is that the previous test makes use of the same route without any issue, so it's proof that

get(route('activity.show', $activity));

works as intended;

Nerijus avatar

You are missing a view. View [activities.show] not found

teebee avatar

If that were the case, shouldn't any other test making use of the same route fail as well? For example the test case right above the one throwing the error, makes use of the same get(route(...)) call, and that test is passing just fine.

davidvm avatar

Not sure if you still have this error, but the view is called activity.show. Made the same mistake in my tests :)