Skip to content

mention old way to create PHPUnit mock objects #7869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions create_framework/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ We are now ready to write our first test::
private function getFrameworkForException($exception)
{
$matcher = $this->createMock(Routing\Matcher\UrlMatcherInterface::class);
// use getMock() on PHPUnit 5.3 or below
// $matcher = $this->getMock(Routing\Matcher\UrlMatcherInterface::class);

$matcher
->expects($this->once())
->method('match')
Expand Down Expand Up @@ -149,6 +152,9 @@ Response::
public function testControllerResponse()
{
$matcher = $this->createMock(Routing\Matcher\UrlMatcherInterface::class);
// use getMock() on PHPUnit 5.3 or below
// $matcher = $this->getMock(Routing\Matcher\UrlMatcherInterface::class);

$matcher
->expects($this->once())
->method('match')
Expand Down
2 changes: 2 additions & 0 deletions form/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ allows you to return a list of extensions to register::
protected function getExtensions()
{
$validator = $this->createMock(ValidatorInterface::class);
// use getMock() on PHPUnit 5.3 or below
// $validator = $this->getMock(ValidatorInterface::class);
$validator
->method('validate')
->will($this->returnValue(new ConstraintViolationList()));
Expand Down
2 changes: 2 additions & 0 deletions testing/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ it's easy to pass a mock object within a test::
{
// First, mock the object to be used in the test
$employee = $this->createMock(Employee::class);
// use getMock() on PHPUnit 5.3 or below
// $employee = $this->getMock(Employee::class);
$employee->expects($this->once())
->method('getSalary')
->will($this->returnValue(1000));
Expand Down