Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d4e5f05

Browse filesBrowse files
committed
Merge branch '6.4' into 7.2
* 6.4: Use phpunit 10 in Create Framework tutorial
2 parents 0a2807f + a0651a2 commit d4e5f05
Copy full SHA for d4e5f05

File tree

1 file changed

+12
-12
lines changed
Filter options

1 file changed

+12
-12
lines changed

‎create_framework/unit_testing.rst

Copy file name to clipboardExpand all lines: create_framework/unit_testing.rst
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using `PHPUnit`_. At first, install PHPUnit as a development dependency:
1212

1313
.. code-block:: terminal
1414
15-
$ composer require --dev phpunit/phpunit:^9.6
15+
$ composer require --dev phpunit/phpunit:^10.0
1616
1717
Then, create a PHPUnit configuration file in ``example.com/phpunit.xml.dist``:
1818

@@ -21,16 +21,16 @@ Then, create a PHPUnit configuration file in ``example.com/phpunit.xml.dist``:
2121
<?xml version="1.0" encoding="UTF-8"?>
2222
<phpunit
2323
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
24+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
2525
backupGlobals="false"
2626
colors="true"
2727
bootstrap="vendor/autoload.php"
2828
>
29-
<coverage processUncoveredFiles="true">
29+
<source>
3030
<include>
3131
<directory suffix=".php">./src</directory>
3232
</include>
33-
</coverage>
33+
</source>
3434
3535
<testsuites>
3636
<testsuite name="Test Suite">
@@ -103,12 +103,12 @@ We are now ready to write our first test::
103103
$matcher
104104
->expects($this->once())
105105
->method('match')
106-
->will($this->throwException($exception))
106+
->willThrowException($exception)
107107
;
108108
$matcher
109109
->expects($this->once())
110110
->method('getContext')
111-
->will($this->returnValue($this->createMock(Routing\RequestContext::class)))
111+
->willReturn($this->createMock(Routing\RequestContext::class))
112112
;
113113
$controllerResolver = $this->createMock(ControllerResolverInterface::class);
114114
$argumentResolver = $this->createMock(ArgumentResolverInterface::class);
@@ -161,16 +161,16 @@ Response::
161161
$matcher
162162
->expects($this->once())
163163
->method('match')
164-
->will($this->returnValue([
164+
->willReturn([
165165
'_route' => 'is_leap_year/{year}',
166166
'year' => '2000',
167167
'_controller' => [new LeapYearController(), 'index'],
168-
]))
168+
])
169169
;
170170
$matcher
171171
->expects($this->once())
172172
->method('getContext')
173-
->will($this->returnValue($this->createMock(Routing\RequestContext::class)))
173+
->willReturn($this->createMock(Routing\RequestContext::class))
174174
;
175175
$controllerResolver = new ControllerResolver();
176176
$argumentResolver = new ArgumentResolver();
@@ -194,7 +194,7 @@ coverage feature (you need to enable `XDebug`_ first):
194194
195195
$ ./vendor/bin/phpunit --coverage-html=cov/
196196
197-
Open ``example.com/cov/src/Simplex/Framework.php.html`` in a browser and check
197+
Open ``example.com/cov/Simplex/Framework.php.html`` in a browser and check
198198
that all the lines for the Framework class are green (it means that they have
199199
been visited when the tests were executed).
200200

@@ -212,6 +212,6 @@ Symfony code.
212212
Now that we are confident (again) about the code we have written, we can
213213
safely think about the next batch of features we want to add to our framework.
214214

215-
.. _`PHPUnit`: https://docs.phpunit.de/en/9.6/
216-
.. _`test doubles`: https://docs.phpunit.de/en/9.6/test-doubles.html
215+
.. _`PHPUnit`: https://docs.phpunit.de/en/10.0/
216+
.. _`test doubles`: https://docs.phpunit.de/en/10.0/test-doubles.html
217217
.. _`XDebug`: https://xdebug.org/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.