Skip to main content

Registration to Activity

Premium
9 min read

Comments & Discussion

AA
Ali Al Qahtani ✓ Link copied!

aritsan need fix it to artisan in this line:

php aritsan make:test RegisterActivityTest

LA
Luis Antonio Parrado ✓ Link copied!

@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).

JB
jerome borg ✓ Link copied!

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

T
teebee ✓ Link copied!

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.

T
teebee ✓ Link copied!

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;

N
Nerijus ✓ Link copied!

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

T
teebee ✓ Link copied!

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.

D
davidvm ✓ Link copied!

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

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.