Skip to content

Commit

Permalink
[Tests] Streamline
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored and nicolas-grekas committed Oct 31, 2023
1 parent a866ca7 commit 0ed1f63
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Tests/AbstractBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public function testGetRequest()

public function testGetRequestNull()
{
$client = $this->getBrowser();

$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getRequest()".');

$client = $this->getBrowser();
$this->assertNull($client->getRequest());
$client->getRequest();
}

public function testXmlHttpRequest()
Expand Down Expand Up @@ -95,20 +96,22 @@ public function testGetResponse()

public function testGetResponseNull()
{
$client = $this->getBrowser();

$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getResponse()".');

$client = $this->getBrowser();
$this->assertNull($client->getResponse());
$client->getResponse();
}

public function testGetInternalResponseNull()
{
$client = $this->getBrowser();

$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalResponse()".');

$client = $this->getBrowser();
$this->assertNull($client->getInternalResponse());
$client->getInternalResponse();
}

public function testGetContent()
Expand All @@ -131,11 +134,12 @@ public function testGetCrawler()

public function testGetCrawlerNull()
{
$client = $this->getBrowser();

$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getCrawler()".');

$client = $this->getBrowser();
$this->assertNull($client->getCrawler());
$client->getCrawler();
}

public function testRequestHttpHeaders()
Expand Down Expand Up @@ -384,7 +388,7 @@ public function testSubmitPreserveAuth()
$this->assertSame('bar', $server['PHP_AUTH_PW']);
}

public function testSubmitPassthrewHeaders()
public function testSubmitPassthroughHeaders()
{
$client = $this->getBrowser();
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
Expand Down Expand Up @@ -623,7 +627,7 @@ public function testFollowMetaRefresh(string $content, string $expectedEndingUrl
$this->assertSame($expectedEndingUrl, $client->getRequest()->getUri());
}

public static function getTestsForMetaRefresh()
public static function getTestsForMetaRefresh(): array
{
return [
['<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'],
Expand Down Expand Up @@ -844,10 +848,11 @@ public function testInternalRequest()

public function testInternalRequestNull()
{
$client = $this->getBrowser();

$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalRequest()".');

$client = $this->getBrowser();
$this->assertNull($client->getInternalRequest());
$client->getInternalRequest();
}
}

0 comments on commit 0ed1f63

Please sign in to comment.