Files
shopit-back/tests/Feature/Integration/TenantIntegrationControllerTest.php
ncoronel ff9d7728e8 Implement localization for API responses and error messages
- Added localization support for API responses in English and Spanish.
- Introduced a middleware to set the API locale based on the Accept-Language header.
- Updated various exception messages and validation responses to use localized strings.
- Created new language files for English and Spanish translations.
- Refactored existing code to replace hardcoded messages with localized strings.
- Added tests to verify localization functionality and response correctness.
2026-07-28 10:19:39 -03:00

48 lines
1.5 KiB
PHP

<?php
namespace Tests\Feature\Integration;
use App\Domains\Integration\Models\Integration;
use App\Domains\Integration\Models\TenantIntegration;
use App\Domains\Integration\Services\TenantIntegrationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Mockery;
use Tests\TestCase;
class TenantIntegrationControllerTest 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',
],
]);
$this->mock(TenantIntegrationService::class, function ($mock) use ($integration) {
$mock->shouldReceive('updateOrCreateIntegration')
->once()
->with(
'test-tenant',
Mockery::on(fn (Integration $argument) => $argument->is($integration)),
['api_key' => 'secret']
)
->andReturn(new TenantIntegration);
});
$this->postJson('/api/test-tenant/integrations/test_integration', [
'integration_data' => [
'api_key' => 'secret',
],
])->assertOk()
->assertExactJson([
'code' => 'integration.configured',
'message' => 'Integración configurada correctamente.',
]);
}
}