Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#5649 from macnibblet/f…
Browse files Browse the repository at this point in the history
…eature/test-http-controller-reasons-phrase

Added a assertion method for the response phrase of a http response.
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/PHPUnit/Controller/AbstractHttpControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ protected function getResponseHeader($header)
return $responseHeader;
}

/**
* Assert response has the given reason phrase
*
* @param string $phrase
*/
public function assertResponseReasonPhrase($phrase)
{
$this->assertEquals($phrase, $this->getResponse()->getReasonPhrase());
}

/**
* Assert response header exists
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,13 @@ public function testAssertApplicationEvents()
$this->assertEquals(true, $viewModel instanceof ViewModel);
$this->assertEquals($viewModel->getTemplate(), 'baz/index/unittests');
}

public function testAssertResponseReasonPhrase()
{
$this->dispatch('/tests');
$this->assertResponseReasonPhrase('OK');

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->assertResponseReasonPhrase('NOT OK');
}
}

0 comments on commit 2e5aa56

Please # to comment.