- Add Metered and ConvexSol (CoTURN) provider drivers with response validation and caching - Add IceCandidateManager with automatic failover and structured logging - Add IceCandidateProviderInterface and DTOs conforming to RTCIceServer format
55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\DTOs\IceCandidateDto;
|
|
use App\DTOs\IceCandidatesDto;
|
|
use App\Http\Resources\Interview\IceCandidateResource;
|
|
use App\Http\Resources\Interview\IceCandidatesResource;
|
|
use Illuminate\Http\Request;
|
|
use Tests\TestCase;
|
|
|
|
class IceCandidatesResourceTest extends TestCase
|
|
{
|
|
public function test_ice_candidate_resource_transforms_individual_dto(): void
|
|
{
|
|
$dto = new IceCandidateDto(
|
|
urls: ['turn:turn.convexsol.com:3478'],
|
|
username: 'convex_user',
|
|
credential: 'password123'
|
|
);
|
|
|
|
$resource = new IceCandidateResource($dto);
|
|
$array = $resource->toArray(Request::create('/ice-servers', 'GET'));
|
|
|
|
$this->assertEquals(['turn:turn.convexsol.com:3478'], $array['urls']);
|
|
$this->assertEquals('convex_user', $array['username']);
|
|
$this->assertEquals('password123', $array['credential']);
|
|
}
|
|
|
|
public function test_ice_candidates_resource_formats_json_array_without_data_wrap(): void
|
|
{
|
|
$dto = new IceCandidatesDto([
|
|
new IceCandidateDto(urls: 'stun:stun.l.google.com:19302'),
|
|
new IceCandidateDto(
|
|
urls: ['turn:turn.convexsol.com:3478'],
|
|
username: 'convex_user',
|
|
credential: 'password123'
|
|
),
|
|
]);
|
|
|
|
$resource = new IceCandidatesResource($dto);
|
|
$request = Request::create('/ice-servers', 'GET');
|
|
$response = $resource->toResponse($request);
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
|
|
$data = $response->getData(true);
|
|
$this->assertIsArray($data);
|
|
$this->assertCount(2, $data);
|
|
$this->assertEquals('stun:stun.l.google.com:19302', $data[0]['urls']);
|
|
$this->assertEquals('convex_user', $data[1]['username']);
|
|
$this->assertEquals('password123', $data[1]['credential']);
|
|
}
|
|
}
|