Files

47 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2026-07-18 15:25:56 +03:00
<?php
use App\Models\SocialAccount;
test('it lists all social accounts including password', function () {
SocialAccount::factory()->count(3)->create();
$response = $this->getJson('/api/accounts');
$response->assertOk()->assertJsonCount(3, 'data');
expect($response->json('data.0'))->toHaveKey('password');
});
test('it filters accounts by network', function () {
SocialAccount::factory()->create(['network' => 'twitter']);
SocialAccount::factory()->create(['network' => 'instagram']);
$response = $this->getJson('/api/accounts?network=twitter');
$response->assertOk()
->assertJsonCount(1, 'data')
->assertJsonPath('data.0.network', 'twitter');
});
test('it filters accounts by type', function () {
SocialAccount::factory()->create(['type' => 'post']);
SocialAccount::factory()->create(['type' => 'like']);
$response = $this->getJson('/api/accounts?type=post');
$response->assertOk()
->assertJsonCount(1, 'data')
->assertJsonPath('data.0.type', 'post');
});
test('it shows a single account with password', function () {
$account = SocialAccount::factory()->create(['password' => 'super-secret']);
$response = $this->getJson("/api/accounts/{$account->id}");
$response->assertOk()->assertJsonPath('data.password', 'super-secret');
});
test('it returns 404 for a missing account', function () {
$this->getJson('/api/accounts/999')->assertNotFound();
});