owen-it / laravel-auditing

Record the change log from models in Laravel
https://laravel-auditing.com
MIT License
3.01k stars 387 forks source link

Especify datatype on AuditableTransitionException #776

Closed erikn69 closed 1 year ago

erikn69 commented 1 year ago

On PHP <=8.0 gettype($audit->auditable_id) is always a string, I don't know if it's a sqlite problem, I did make this PR showing this behaivor

1) OwenIt\Auditing\Tests\AuditableTest::itFailsToTransitionWhenTheAuditAuditableIdDoesNotMatchTheModelId
Failed asserting that exception message 
    'Expected Auditable id (integer)2, got (string)1 instead' 
contains 
    'Expected Auditable id (integer)2, got (integer)1 instead'.
erikn69 commented 1 year ago

https://github.com/laravel/framework/issues/3548#issuecomment-1082763785

I was running php 8.1.1 (due to M1 compatibility), whereas the GitHub actions where hardcoded to PHP 8.0. Setting those to 8.1.1 made the problem go away. (I read somewhere this issue was fixed in php 8.1).