I am writing a unit test and checking in pivot table if has some keys and throws error for undefined function. That function is for php 7.3 but laravel 7 requirement is 7.2.5+ right?
Why trait is using functions that are for 7.3 php version?
I am doing anything wrong?
Create a table and add some records.
Create a test add assertion like this.
$this->assertDatabaseHas('user_role', [
'user_id' => $user->id,
'role_id' => $role->id,
]);
It would be helpful if you shared the exact error message you get, preferably the whole stack trace.
Hello @lupinitylabs ,
This is the strack trace
Error : Call to undefined function Illuminate\Testing\Constraints\array_key_first()
C:\laragon\www\laravel\vendor\laravel\framework\src\Illuminate\Testing\Constraints\HasInDatabase.php:81
C:\laragon\www\laravel\vendor\laravel\framework\src\Illuminate\Testing\Constraints\HasInDatabase.php:66
C:\laragon\www\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase.php:46
C:\laragon\www\laravel\tests\Http\Controllers\System\UserRoleController\DestroyTest.php:52
under further investigation, it looks that the current error occurs when the values you are looking are not in the table and the data are empty or missing the looking ids
Good find! Shows how important a good test coverage really is.
Actually this is tested, but the tests load the PHP 7.3 polyfill...
I was just going to ask that :-)Thanks for fixing!
@lupinitylabs Thanks,testing is crucial indeed
Actually this is tested, but the tests load the PHP 7.3 polyfill...
This is now fixed on 6.x and 7.x.
Most helpful comment
This is now fixed on 6.x and 7.x.