32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\SuiteCrm;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
use Tests\TestCase;
|
|
|
|
class SuiteCrmProbeTest extends TestCase
|
|
{
|
|
public function test_disabled_probe_does_not_contact_crm(): void
|
|
{
|
|
Http::preventStrayRequests();
|
|
config(['suitecrm.enabled' => false]);
|
|
$this->artisan('suitecrm:probe')->expectsOutput('SuiteCRM indisponivel: disabled')->assertFailed();
|
|
Http::assertNothingSent();
|
|
}
|
|
|
|
public function test_probe_reads_metadata_without_writing_business_records(): void
|
|
{
|
|
config(['suitecrm.enabled' => true, 'suitecrm.base_url' => 'https://crm.example.invalid/legacy',
|
|
'suitecrm.client_id' => 'probe', 'suitecrm.client_secret' => 'private-probe-secret', 'suitecrm.cache_store' => 'array']);
|
|
Http::preventStrayRequests();
|
|
Http::fake([
|
|
'*/Api/access_token' => Http::response(['access_token' => 'private-token', 'token_type' => 'Bearer', 'expires_in' => 3600]),
|
|
'*/Api/V8/meta/fields/Contacts' => Http::response(['data' => ['type' => 'fields', 'attributes' => ['last_name' => ['type' => 'varchar']]]]),
|
|
]);
|
|
$this->artisan('suitecrm:probe')->assertSuccessful();
|
|
Http::assertSentCount(2);
|
|
Http::assertNotSent(fn ($request) => str_contains($request->url(), '/module'));
|
|
}
|
|
}
|