Skip to content

Commit ecec417

Browse files
committed
mention old way to create PHPUnit mock objects
1 parent 2542b36 commit ecec417

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

create_framework/unit_testing.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ We are now ready to write our first test::
9393
private function getFrameworkForException($exception)
9494
{
9595
$matcher = $this->createMock(Routing\Matcher\UrlMatcherInterface::class);
96+
// use getMock() on PHPUnit 5.3 or below
97+
// $matcher = $this->getMock(Routing\Matcher\UrlMatcherInterface::class);
98+
9699
$matcher
97100
->expects($this->once())
98101
->method('match')
@@ -149,6 +152,9 @@ Response::
149152
public function testControllerResponse()
150153
{
151154
$matcher = $this->createMock(Routing\Matcher\UrlMatcherInterface::class);
155+
// use getMock() on PHPUnit 5.3 or below
156+
// $matcher = $this->getMock(Routing\Matcher\UrlMatcherInterface::class);
157+
152158
$matcher
153159
->expects($this->once())
154160
->method('match')

form/unit_testing.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ allows you to return a list of extensions to register::
185185
protected function getExtensions()
186186
{
187187
$validator = $this->createMock(ValidatorInterface::class);
188+
// use getMock() on PHPUnit 5.3 or below
189+
// $validator = $this->getMock(ValidatorInterface::class);
188190
$validator
189191
->method('validate')
190192
->will($this->returnValue(new ConstraintViolationList()));

testing/database.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ it's easy to pass a mock object within a test::
7171
{
7272
// First, mock the object to be used in the test
7373
$employee = $this->createMock(Employee::class);
74+
// use getMock() on PHPUnit 5.3 or below
75+
// $employee = $this->getMock(Employee::class);
7476
$employee->expects($this->once())
7577
->method('getSalary')
7678
->will($this->returnValue(1000));

0 commit comments

Comments
 (0)