How to unit test? #1005
-
I'm using PHPUnit to test MyModel and assuming MyModel is correctly implemented and the installation instructions were followed, is this how I would test the model in theory? namespace Tests\Feature;
use App\Models\MyModel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use OwenIt\Auditing\Models\Audit;
use Tests\TestCase;
class AuditingTest extends TestCase
{
use RefreshDatabase;
public function test_it_tracks_changes_to_my_model()
{
$myModel = MyModel::create([
'name' => 'foo',
'value' => 'bar'
]);
$myModel->update(['value' => 'Updated value']);
$audit = Audit::where('auditable_id', $myModel->id)
->where('auditable_type', MyModel::class);
$this->assertNotNull($audit); // is failing
$audit = $myModel->audits()->first();
$this->assertNotNull($audit); // is also failing
}
} I ask because |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
laravel-auditing/config/audit.php Lines 188 to 197 in 2c2b9c7 |
Beta Was this translation helpful? Give feedback.
laravel-auditing/config/audit.php
Lines 188 to 197 in 2c2b9c7