76 lines
2.0 KiB
PHP
76 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Website;
|
|
|
|
use App\Models\Website\AboutMe;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class AboutMeTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_can_get_about_me()
|
|
{
|
|
$aboutMe = AboutMe::factory()->create();
|
|
|
|
$response = $this->getJson('/api/website/about-me');
|
|
|
|
$response->assertStatus(200);
|
|
}
|
|
|
|
public function test_can_get_about_me_translation()
|
|
{
|
|
$aboutMe = AboutMe::factory()->create();
|
|
$aboutMe->setTranslation('title', 'en', 'Hello');
|
|
$aboutMe->setTranslation('description', 'en', 'Description');
|
|
$aboutMe->save();
|
|
|
|
$response = $this->getJson("/api/website/about-me/{$aboutMe->id}/translation/en");
|
|
|
|
$response->assertStatus(200)
|
|
->assertJson(['title' => 'Hello']);
|
|
}
|
|
|
|
public function test_returns_404_for_missing_translation()
|
|
{
|
|
$aboutMe = AboutMe::factory()->create();
|
|
|
|
$response = $this->getJson("/api/website/about-me/{$aboutMe->id}/translation/de");
|
|
|
|
$response->assertStatus(404);
|
|
}
|
|
|
|
public function test_can_create_about_me()
|
|
{
|
|
$response = $this->postJson('/api/website/about-me', [
|
|
'image' => 'test.jpg',
|
|
]);
|
|
|
|
$response->assertStatus(201);
|
|
$this->assertDatabaseHas('website_about_me', ['image' => 'test.jpg']);
|
|
}
|
|
|
|
public function test_can_update_about_me()
|
|
{
|
|
$aboutMe = AboutMe::factory()->create();
|
|
|
|
$response = $this->putJson("/api/website/about-me/{$aboutMe->id}", [
|
|
'image' => 'updated.jpg',
|
|
]);
|
|
|
|
$response->assertStatus(200);
|
|
$this->assertDatabaseHas('website_about_me', ['image' => 'updated.jpg']);
|
|
}
|
|
|
|
public function test_can_delete_about_me()
|
|
{
|
|
$aboutMe = AboutMe::factory()->create();
|
|
|
|
$response = $this->deleteJson("/api/website/about-me/{$aboutMe->id}");
|
|
|
|
$response->assertStatus(204);
|
|
$this->assertDatabaseMissing('website_about_me', ['id' => $aboutMe->id]);
|
|
}
|
|
}
|