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\Feature\Website;
|
||||
|
||||
use App\Models\Website\Project;
|
||||
use App\Models\Website\ProjectCategory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProjectTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_can_list_projects()
|
||||
{
|
||||
$category = ProjectCategory::factory()->create();
|
||||
$category->setTranslation('title', 'fa', 'دسته');
|
||||
$category->save();
|
||||
|
||||
$project = Project::factory()->create(['category_id' => $category->id]);
|
||||
$project->setTranslation('title', 'fa', 'پروژه');
|
||||
$project->setTranslation('description', 'fa', 'توضیحات');
|
||||
$project->save();
|
||||
|
||||
$response = $this->getJson('/api/website/projects/translation/fa');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonStructure(['projects', 'categories']);
|
||||
}
|
||||
|
||||
public function test_can_get_single_project()
|
||||
{
|
||||
$category = ProjectCategory::factory()->create();
|
||||
$project = Project::factory()->create(['category_id' => $category->id]);
|
||||
|
||||
$response = $this->getJson("/api/website/projects/{$project->id}/translation/en");
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user