1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-08 01:10:08 +01:00

test case updated

This commit is contained in:
Afjalur Rahman Rana
2023-12-05 11:23:24 +00:00
parent e829a1cf31
commit ec7046f3a7
2 changed files with 7 additions and 12 deletions

View File

@@ -58,7 +58,7 @@ public function findHttpTunnelUrl(array $tunnels, string $domain): ?string
// If there are active tunnels on the Ngrok instance we will spin through them and // If there are active tunnels on the Ngrok instance we will spin through them and
// find the one responding on HTTP. Each tunnel has an HTTP and a HTTPS address // find the one responding on HTTP. Each tunnel has an HTTP and a HTTPS address
foreach ($tunnels as $tunnel) { foreach ($tunnels as $tunnel) {
if (($tunnel->proto === 'http' || $tunnel->proto === 'https') && strpos($tunnel->config->addr, strtolower($domain))) { if (($tunnel->proto === 'http' || $tunnel->proto === 'https') && stripos($tunnel->config->addr, $domain)) {
return $tunnel->public_url; return $tunnel->public_url;
} }
} }

View File

@@ -31,26 +31,21 @@ public function test_it_matches_correct_share_tunnel()
'config' => (object) [ 'config' => (object) [
'addr' => 'http://mysite.test:80', 'addr' => 'http://mysite.test:80',
], ],
'public_url' => 'http://bad-proto.ngrok.io/', 'public_url' => 'https://right-one.ngrok.io/',
], ],
(object) [ (object) [
'proto' => 'http', 'proto' => 'http',
'config' => (object) [ 'config' => (object) [
'addr' => 'http://nottherightone.test:80', 'addr' => 'http://mynewsite.test:80',
], ],
'public_url' => 'http://bad-site.ngrok.io/', 'public_url' => 'http://new-right-one.ngrok.io/',
],
(object) [
'proto' => 'http',
'config' => (object) [
'addr' => 'http://mysite.test:80',
],
'public_url' => 'http://right-one.ngrok.io/',
], ],
]; ];
$ngrok = resolve(Ngrok::class); $ngrok = resolve(Ngrok::class);
$this->assertEquals('http://right-one.ngrok.io/', $ngrok->findHttpTunnelUrl($tunnels, 'mysite')); $this->assertEquals('https://right-one.ngrok.io/', $ngrok->findHttpTunnelUrl($tunnels, 'mysite'));
$this->assertEquals('http://new-right-one.ngrok.io/', $ngrok->findHttpTunnelUrl($tunnels, 'mynewsite'));
} }
public function test_it_checks_against_lowercased_domain() public function test_it_checks_against_lowercased_domain()