Skip to content

How to write Laravel unit tests when the field name/id is randomized #137

Closed Answered by carbtest
carbtest asked this question in Q&A
Discussion options

You must be logged in to vote

after digging some more I found the config()->set() function

public function test_honepot_registration_fails(): void
    {
        config()->set('honeypot.randomize_name_field_name', false);
        $this->seed(RoleAndPermissionSeeder::class);
        $response = $this->post('/register', [
            'name' => 'Test User',
            'email' => 'test@example.com',
            'password' => 'password',
            'password_confirmation' => 'password',
            'my_name' => 'filled by bot'
        ])->assertDontSee('verify')
            ->assertLocation('/');

        $this->assertGuest();
    }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by carbtest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant