You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
826 B
29 lines
826 B
<?php
|
|
|
|
namespace Tests\Unit\Domains\System\Traits\Model;
|
|
|
|
use App\Domains\System\Traits\Model\HasFile;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
test('it returns correct morph relation for single file', function () {
|
|
$model = new class extends Model {
|
|
use HasFile;
|
|
protected $table = 'test_models';
|
|
};
|
|
|
|
expect($model->hasSingleFile('avatar'))->toBeInstanceOf(MorphOne::class);
|
|
});
|
|
|
|
test('it returns correct morph relation for multi file', function () {
|
|
$model = new class extends Model {
|
|
use HasFile;
|
|
protected $table = 'test_models';
|
|
};
|
|
|
|
expect($model->hasMultiFile('documents'))->toBeInstanceOf(MorphMany::class);
|
|
});
|
|
|