Files
shopit-back/tests/Feature/Integration/ClientIntegrationControllerTest.php
ncoronel d73b4d1daf feat: Introduce client management and integration updates
- Added client_id field to StoreTenantRequest and UpdateTenantRequest for tenant management.
- Updated TenantResource to include client_id in the response.
- Created migration to establish clients table and link tenants to clients.
- Migrated existing tenant integrations to client_integrations table.
- Grouped specific tenants under a shared client (OnTicket) in a new migration.
- Updated seeders to reflect new client structure and relationships.
- Adjusted integration configurations to require client instead of tenant.
- Added tests for client integration functionality and ensured existing tests reflect the new client structure.
2026-08-18 16:18:34 -03:00

50 lines
1.7 KiB
PHP

<?php
namespace Tests\Feature\Integration;
use App\Domains\Client\Models\Client;
use App\Domains\Integration\Models\ClientIntegration;
use App\Domains\Integration\Models\Integration;
use App\Domains\Integration\Services\ClientIntegrationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Mockery;
use Tests\TestCase;
class ClientIntegrationControllerTest extends TestCase
{
use RefreshDatabase;
public function test_store_returns_success_message_without_integration_data(): void
{
$integration = Integration::create([
'integration_code' => 'test_integration',
'name' => 'Test Integration',
'integration_data_schema' => [
'api_key' => 'required|string',
],
]);
$client = Client::query()->create(['code' => 'test-client', 'name' => 'Test Client']);
$this->mock(ClientIntegrationService::class, function ($mock) use ($client, $integration) {
$mock->shouldReceive('updateOrCreateIntegration')
->once()
->with(
Mockery::on(fn (Client $argument) => $argument->is($client)),
Mockery::on(fn (Integration $argument) => $argument->is($integration)),
['api_key' => 'secret']
)
->andReturn(new ClientIntegration);
});
$this->putJson('/api/clients/test-client/integrations/test_integration', [
'integration_data' => [
'api_key' => 'secret',
],
])->assertOk()
->assertExactJson([
'code' => 'integration.configured',
'message' => 'Integración configurada correctamente.',
]);
}
}