Question: I have a metadata table and need to test inserting data:

```
public function test_insert_unique_data()
{
    $response = Metadata::create([
        'metable_id' => '1',
        'metable_type' => File::class,
        'type' => 'resolution',
        'key' => 'width',
        'value' => 1000,
    ]);

    $response->assertCreated();
}

```

This is the migration for the table:

```
Schema::create(..., function (Blueprint $table) {
    $table->id();
    $table->bigInteger('metable_id')->unsigned()->index();
    $table->string('metable_type')->index();
    $table->string('type')->default('default');
    $table->string('key')->index();
    $table->text('value');
    $table->timestamps();
});

```

It's failing every time so I can only assume the test is written wrong. Any pointers please?

Answer: 
Why not just use a factory? They have all sorts of assertions in their [Database testing](https://laravel.com/docs/8.x/database-testing#available-assertions) section.

Unless there's a reason for it, every testing that uses any models I'm seeing in modern Laravel (I come from Laravel 3-5 days) is using factories.
I don't know about this `assertCreated` function but I know of something similar:

```php
public function test_insert_unique_data()
{
    $metadata = Metadata::create([
        'metable_id' => '1',
        'metable_type' => File::class,
        'type' => 'resolution',
        'key' => 'width',
        'value' => 1000,
    ]);

    $this->assertModelExists($metadata);
}

```