Skip to content

Commit 2360815

Browse files
committed
Make ->withHost available when using visit(..)
1 parent d07e6ba commit 2360815

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Api/PendingAwaitablePage.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ public function withUserAgent(string $userAgent): self
118118
]);
119119
}
120120

121+
/**
122+
* Sets the host for the server.
123+
*/
124+
public function withHost(string $host): self
125+
{
126+
Playwright::setHost($host);
127+
128+
return new self($this->browserType, $this->device, $this->url, $this->options);
129+
}
130+
121131
/**
122132
* Sets the timezone for the page.
123133
*/

tests/Browser/Visit/SubdomainTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
</html>
1616
');
1717

18-
pest()->browser()->withHost('app.localhost');
19-
2018
visit('/app-test')
19+
->withHost('app.localhost')
2120
->assertSee('Welcome to NON Subdomain')
2221
->assertSeeIn('#content', 'This is the non subdomain content')
2322
->assertTitle('Non Subdomain');
@@ -33,9 +32,8 @@
3332
]);
3433
});
3534

36-
pest()->browser()->withHost('api.localhost');
37-
3835
visit('/api/health')
36+
->withHost('api.localhost')
3937
->assertSee('"status":"ok"')
4038
->assertSee('"subdomain":"api"')
4139
->assertSee('"host":"api.localhost"');

0 commit comments

Comments
 (0)