setAccessible(true); return $reflection->invoke(new AgentDomainService(), $value); } public function test_bound_value_is_kept_exactly_and_host_is_extracted(): void { foreach ([ 'https://pc.example.com' => 'pc.example.com', ' https://pc.example.com/#/user/register?ref=A1 ' => 'pc.example.com', 'h5.Example.com/reg' => 'h5.example.com', 'http://pc.example.com:8080/x' => 'pc.example.com', ] as $input => $host) { $this->assertSame(trim($input), $this->call('normalize', $input), 'saved exactly as entered (only trimmed)'); $this->assertSame($host, $this->call('host', trim($input))); } $this->assertSame('', $this->call('normalize', ' ')); foreach (['ftp://pc.example.com', 'https://', 'pc example.com'] as $bad) { try { $this->call('normalize', $bad); $this->fail($bad); } catch (\InvalidArgumentException $e) { $this->assertSame('域名格式错误', $e->getMessage()); } } } }