fix tests isssues
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m24s
API CI/CD / Build frontend assets (push) Successful in 2m25s
API CI/CD / Security audit (push) Successful in 32s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped

This commit is contained in:
root
2026-06-24 00:56:12 -04:00
parent 2e0bc37d91
commit baa6fff459
3 changed files with 28 additions and 18 deletions
@@ -2,15 +2,26 @@
namespace Tests\Feature\Api;
use App\Models\User;
use App\Services\AttendanceCommentTemplateService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Laravel\Sanctum\Sanctum;
use Mockery;
use Tests\TestCase;
class AttendanceCommentTemplateApiTest extends TestCase
{
use RefreshDatabase;
use WithFaker;
protected function setUp(): void
{
parent::setUp();
$user = User::factory()->create();
Sanctum::actingAs($user);
}
protected function tearDown(): void
{
Mockery::close();
@@ -42,7 +53,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
$response = $this->getJson('/api/attendance-comment-templates');
$response = $this->getJson('/api/v1/attendance-comment-templates');
$response->assertOk()
->assertJson([
@@ -63,7 +74,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
$response = $this->getJson('/api/attendance-comment-templates?active_only=1');
$response = $this->getJson('/api/v1/attendance-comment-templates?active_only=1');
$response->assertOk()
->assertJson([
@@ -100,7 +111,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
$response = $this->postJson('/api/attendance-comment-templates', $payload);
$response = $this->postJson('/api/v1/attendance-comment-templates', $payload);
$response->assertCreated()
->assertJsonPath('status', 'success')
@@ -118,7 +129,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
'is_active' => true,
];
$response = $this->postJson('/api/attendance-comment-templates', $payload);
$response = $this->postJson('/api/v1/attendance-comment-templates', $payload);
$response->assertStatus(422)
->assertJsonValidationErrors(['max_score']);
@@ -140,7 +151,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
$response = $this->getJson('/api/attendance-comment-templates/5');
$response = $this->getJson('/api/v1/attendance-comment-templates/5');
$response->assertOk()
->assertJsonPath('status', 'success')
@@ -171,7 +182,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
$response = $this->putJson('/api/attendance-comment-templates/7', $payload);
$response = $this->putJson('/api/v1/attendance-comment-templates/7', $payload);
$response->assertOk()
->assertJsonPath('status', 'success')
@@ -186,7 +197,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
'max_score' => 20,
];
$response = $this->putJson('/api/attendance-comment-templates/7', $payload);
$response = $this->putJson('/api/v1/attendance-comment-templates/7', $payload);
$response->assertStatus(422)
->assertJsonValidationErrors(['max_score']);
@@ -201,7 +212,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
$response = $this->deleteJson('/api/attendance-comment-templates/12');
$response = $this->deleteJson('/api/v1/attendance-comment-templates/12');
$response->assertOk()
->assertJsonPath('status', 'success')
@@ -226,7 +237,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
$response = $this->getJson('/api/attendance-comment-templates/list-data');
$response = $this->getJson('/api/v1/attendance-comment-templates/list-data');
$response->assertOk()
->assertJsonCount(1, 'templates')