freescout2ant/tests/Feature/CrmServiceTest.php
2025-04-21 21:34:05 +02:00

27 lines
782 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Modules\AmeiseModule\Tests\Feature;
use Tests\TestCase;
use Illuminate\Support\Facades\Http;
use Modules\AmeiseModule\Services\CrmService;
class CrmServiceTest extends TestCase
{
/** @test */
public function it_refreshes_token_and_creates_contact(): void
{
// 1. Fake RefreshAufruf
Http::fakeSequence()
->push(['access_token' => 'NEU', 'refresh_token' => 'X', 'expires_in' => 3600], 200)
// 2. Fake eigentliche APIRoute
->push(['id' => 1, 'name' => 'Max'], 201);
$crm = app(CrmService::class);
$data = $crm->createContact(['name' => 'Max']);
$this->assertEquals(['id' => 1, 'name' => 'Max'], $data);
Http::assertSentCount(2); // Refresh + APICall
}
}