PHP Classes

File: tests/Feature/Auth/PasswordUpdateTest.php

Recommend this page to a friend!
  Classes of Maniruzzaman Akash   Laravel Stripe Checkout   tests/Feature/Auth/PasswordUpdateTest.php   Download  
File: tests/Feature/Auth/PasswordUpdateTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Laravel Stripe Checkout
E-commerce checkout that uses Stripe to pay orders
Author: By
Last change:
Date: 10 months ago
Size: 1,097 bytes
 

Contents

Class file image Download
<?php

use App\Models\User;
use
Illuminate\Support\Facades\Hash;

test('password can be updated', function () {
   
$user = User::factory()->create();

   
$response = $this
       
->actingAs($user)
        ->
from('/profile')
        ->
put('/password', [
           
'current_password' => 'password',
           
'password' => 'new-password',
           
'password_confirmation' => 'new-password',
        ]);

   
$response
       
->assertSessionHasNoErrors()
        ->
assertRedirect('/profile');

   
$this->assertTrue(Hash::check('new-password', $user->refresh()->password));
});

test('correct password must be provided to update password', function () {
   
$user = User::factory()->create();

   
$response = $this
       
->actingAs($user)
        ->
from('/profile')
        ->
put('/password', [
           
'current_password' => 'wrong-password',
           
'password' => 'new-password',
           
'password_confirmation' => 'new-password',
        ]);

   
$response
       
->assertSessionHasErrorsIn('updatePassword', 'current_password')
        ->
assertRedirect('/profile');
});