@Sinnbeck Hi, thank for the replic. It is something gereric like that:
class UserTest extends ModelTestCase
{
protected function model(): Model
{
return new User();
}
protected function traits(): array
{
return [
HasFactory::class,
SoftDeletes::class,
LogsActivity::class,
Searchable::class,
];
}
protected function fillable(): array
{
return [
'name',
'email',
];
}
protected function casts(): array
{
return [
'id' => 'int',
'deleted_at' => 'datetime',
];
}
}
The ModelTestCase:
namespace Tests\Unit\App\Models;
use Illuminate\Database\Eloquent\Model;
use PHPUnit\Framework\TestCase;
abstract class ModelTestCase extends TestCase
{
abstract protected function model(): Model;
abstract protected function traits(): array;
abstract protected function fillable(): array;
abstract protected function casts(): array;
public function test_traits()
{
$traits = array_keys(class_uses($this->model()));
$this->assertEquals($this->traits(), $traits);
}
public function test_fillable()
{
$fillable = $this->model()->getFillable();
$this->assertEquals($this->fillable(), $fillable);
}
public function test_has_casts()
{
$casts = $this->model()->getCasts();
$this->assertEquals($this->casts(), $casts);
}
}
And in my model
use Laravel\Scout\Searchable
class User extends Model implements Explored { use HasFactory, SoftDeletes, LogsActivity, Searchable; }
Every tests works fine, but when i have implemented the laravel scout trait on test(searchable. And laravel scout works very fine when i test manualy) that error is inputed on test.
I'm sorry about the code desgin, it's my very first post on laracast. Thank for your time.