4.1-4.3: add PHPUnit feature tests for all endpoints + factories
This commit is contained in:
1 parent
afb202f333
commit
9ff5b93157
16 files changed
+504
-37
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Website\AboutMe;
|
||||
use App\Models\Website\Skill;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ModelsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_about_me_can_set_and_get_translations()
|
||||
{
|
||||
$aboutMe = AboutMe::factory()->create();
|
||||
|
||||
$aboutMe->setTranslation('title', 'en', 'Hello');
|
||||
$aboutMe->setTranslation('title', 'fa', 'سلام');
|
||||
$aboutMe->save();
|
||||
|
||||
$this->assertEquals('Hello', $aboutMe->getTranslation('title', 'en'));
|
||||
$this->assertEquals('سلام', $aboutMe->getTranslation('title', 'fa'));
|
||||
}
|
||||
|
||||
public function test_about_me_has_skills_relation()
|
||||
{
|
||||
$aboutMe = AboutMe::factory()->create();
|
||||
Skill::factory()->count(2)->create(['about_me_id' => $aboutMe->id]);
|
||||
|
||||
$this->assertCount(2, $aboutMe->skills);
|
||||
}
|
||||
|
||||
public function test_about_me_fillable_fields()
|
||||
{
|
||||
$aboutMe = AboutMe::factory()->create(['image' => 'photo.jpg']);
|
||||
|
||||
$this->assertEquals('photo.jpg', $aboutMe->image);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user