Spaces:
Runtime error
Runtime error
| namespace Tests\Unit; | |
| use App\Domain\Applications\ApplicationService; | |
| use App\Domain\Contracts\ContractService; | |
| use App\Domain\Identity\ClientOnboardingService; | |
| use App\Support\PlatformUrl; | |
| use ReflectionClass; | |
| use Tests\TestCase; | |
| class PlatformUrlTest extends TestCase | |
| { | |
| public function test_platform_urls_join_paths_without_duplicate_slashes(): void | |
| { | |
| config([ | |
| 'platform.backend_app_url' => 'https://clientportaldev.qhtestingserver.com/diaspora_nexus_backend', | |
| 'platform.backend_api_base_url' => 'https://clientportaldev.qhtestingserver.com/diaspora_nexus_backend/api/v1', | |
| 'platform.website_url' => 'https://clientportaldev.qhtestingserver.com/diaspora-nexus', | |
| 'platform.admin_portal_url' => 'https://clientportaldev.qhtestingserver.com/admin_portal', | |
| 'platform.client_portal_url' => 'https://clientportaldev.qhtestingserver.com/portal', | |
| ]); | |
| $this->assertSame('https://clientportaldev.qhtestingserver.com/diaspora_nexus_backend', PlatformUrl::backendApp()); | |
| $this->assertSame('https://clientportaldev.qhtestingserver.com/diaspora_nexus_backend/api/v1', PlatformUrl::backendApi()); | |
| $this->assertSame('https://clientportaldev.qhtestingserver.com/diaspora-nexus/payment', PlatformUrl::website('/payment')); | |
| $this->assertSame('https://clientportaldev.qhtestingserver.com/admin_portal/review', PlatformUrl::adminPortal('review')); | |
| $this->assertSame('https://clientportaldev.qhtestingserver.com/portal/dashboard', PlatformUrl::clientPortal('/dashboard')); | |
| } | |
| public function test_contract_signing_url_derives_from_website_url_when_override_is_missing(): void | |
| { | |
| config([ | |
| 'app.membership_contract_signing_url' => null, | |
| 'platform.website_url' => 'https://clientportaldev.qhtestingserver.com/diaspora-nexus', | |
| ]); | |
| $reflection = new ReflectionClass(ContractService::class); | |
| $service = $reflection->newInstanceWithoutConstructor(); | |
| $method = $reflection->getMethod('membershipContractSigningUrl'); | |
| $method->setAccessible(true); | |
| $this->assertSame( | |
| 'https://clientportaldev.qhtestingserver.com/diaspora-nexus/contracts/membership?token=contract-token-123', | |
| $method->invoke($service, 'contract-token-123'), | |
| ); | |
| } | |
| public function test_approval_payment_url_derives_from_website_url_when_override_is_missing(): void | |
| { | |
| config([ | |
| 'app.approval_payment_form_url' => null, | |
| 'platform.website_url' => 'https://clientportaldev.qhtestingserver.com/diaspora-nexus', | |
| ]); | |
| $reflection = new ReflectionClass(ApplicationService::class); | |
| $service = $reflection->newInstanceWithoutConstructor(); | |
| $method = $reflection->getMethod('approvalPaymentUrl'); | |
| $method->setAccessible(true); | |
| $url = $method->invoke($service, 'approval-token-123'); | |
| $parts = parse_url($url); | |
| parse_str($parts['query'] ?? '', $query); | |
| $this->assertSame('https://clientportaldev.qhtestingserver.com/diaspora-nexus/payment', ($parts['scheme'] ?? '').'://'.($parts['host'] ?? '').($parts['path'] ?? '')); | |
| $this->assertSame('membership_fee', $query['payment_type'] ?? null); | |
| $this->assertSame('approval-token-123', $query['approval_token'] ?? null); | |
| } | |
| public function test_client_setup_url_derives_from_website_url_when_override_is_missing(): void | |
| { | |
| config([ | |
| 'app.client_portal_setup_url' => null, | |
| 'platform.website_url' => 'https://clientportaldev.qhtestingserver.com/diaspora-nexus', | |
| ]); | |
| $reflection = new ReflectionClass(ClientOnboardingService::class); | |
| $service = $reflection->newInstanceWithoutConstructor(); | |
| $method = $reflection->getMethod('clientSetupUrl'); | |
| $method->setAccessible(true); | |
| $this->assertSame( | |
| 'https://clientportaldev.qhtestingserver.com/diaspora-nexus/client/setup/setup-token-123', | |
| $method->invoke($service, 'setup-token-123'), | |
| ); | |
| } | |
| } | |