Skip to content

Commit 0ed1f63

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Tests] Streamline
1 parent a866ca7 commit 0ed1f63

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

Tests/AbstractBrowserTest.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ public function testGetRequest()
4747

4848
public function testGetRequestNull()
4949
{
50+
$client = $this->getBrowser();
51+
5052
$this->expectException(BadMethodCallException::class);
5153
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getRequest()".');
5254

53-
$client = $this->getBrowser();
54-
$this->assertNull($client->getRequest());
55+
$client->getRequest();
5556
}
5657

5758
public function testXmlHttpRequest()
@@ -95,20 +96,22 @@ public function testGetResponse()
9596

9697
public function testGetResponseNull()
9798
{
99+
$client = $this->getBrowser();
100+
98101
$this->expectException(BadMethodCallException::class);
99102
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getResponse()".');
100103

101-
$client = $this->getBrowser();
102-
$this->assertNull($client->getResponse());
104+
$client->getResponse();
103105
}
104106

105107
public function testGetInternalResponseNull()
106108
{
109+
$client = $this->getBrowser();
110+
107111
$this->expectException(BadMethodCallException::class);
108112
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalResponse()".');
109113

110-
$client = $this->getBrowser();
111-
$this->assertNull($client->getInternalResponse());
114+
$client->getInternalResponse();
112115
}
113116

114117
public function testGetContent()
@@ -131,11 +134,12 @@ public function testGetCrawler()
131134

132135
public function testGetCrawlerNull()
133136
{
137+
$client = $this->getBrowser();
138+
134139
$this->expectException(BadMethodCallException::class);
135140
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getCrawler()".');
136141

137-
$client = $this->getBrowser();
138-
$this->assertNull($client->getCrawler());
142+
$client->getCrawler();
139143
}
140144

141145
public function testRequestHttpHeaders()
@@ -384,7 +388,7 @@ public function testSubmitPreserveAuth()
384388
$this->assertSame('bar', $server['PHP_AUTH_PW']);
385389
}
386390

387-
public function testSubmitPassthrewHeaders()
391+
public function testSubmitPassthroughHeaders()
388392
{
389393
$client = $this->getBrowser();
390394
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
@@ -623,7 +627,7 @@ public function testFollowMetaRefresh(string $content, string $expectedEndingUrl
623627
$this->assertSame($expectedEndingUrl, $client->getRequest()->getUri());
624628
}
625629

626-
public static function getTestsForMetaRefresh()
630+
public static function getTestsForMetaRefresh(): array
627631
{
628632
return [
629633
['<html><head><meta http-equiv="Refresh" content="4" /><meta http-equiv="refresh" content="0; URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/redirected'],
@@ -844,10 +848,11 @@ public function testInternalRequest()
844848

845849
public function testInternalRequestNull()
846850
{
851+
$client = $this->getBrowser();
852+
847853
$this->expectException(BadMethodCallException::class);
848854
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalRequest()".');
849855

850-
$client = $this->getBrowser();
851-
$this->assertNull($client->getInternalRequest());
856+
$client->getInternalRequest();
852857
}
853858
}

0 commit comments

Comments
 (0)