Skip to content

Commit f5b9fcd

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: use namespaced PHPUnit classes Update event_dispatcher.rst for consistency Made 'create-user' command consistent. Update without_class.rst Fix typo Fixed the way flash messages are retrieved in the template Minor improvement for the default console command article
2 parents eff11ef + ac5835f commit f5b9fcd

10 files changed

+32
-24
lines changed

components/console/changing_default_command.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ name to the ``setDefaultCommand()`` method::
2828
}
2929
}
3030

31-
Executing the application and changing the default Command::
31+
Executing the application and changing the default command::
3232

3333
// application.php
3434

@@ -53,9 +53,10 @@ This will print the following to the command line:
5353
5454
Hello World
5555
56-
.. tip::
56+
.. caution::
5757

58-
This feature has a limitation: you cannot use it with any Command arguments.
58+
This feature has a limitation: you cannot pass any argument or option to
59+
the default command because they are ignored.
5960

6061
Learn More!
6162
-----------

components/event_dispatcher.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ A call to the dispatcher's ``addListener()`` method associates any valid
135135
PHP callable to an event::
136136

137137
$listener = new AcmeListener();
138-
$dispatcher->addListener('acme.action', array($listener, 'onFooAction'));
138+
$dispatcher->addListener('acme.foo.action', array($listener, 'onFooAction'));
139139

140140
The ``addListener()`` method takes up to three arguments:
141141

@@ -161,12 +161,12 @@ The ``addListener()`` method takes up to three arguments:
161161

162162
use Symfony\Component\EventDispatcher\Event;
163163

164-
$dispatcher->addListener('foo.action', function (Event $event) {
165-
// will be executed when the foo.action event is dispatched
164+
$dispatcher->addListener('acme.foo.action', function (Event $event) {
165+
// will be executed when the acme.foo.action event is dispatched
166166
});
167167

168168
Once a listener is registered with the dispatcher, it waits until the event
169-
is notified. In the above example, when the ``foo.action`` event is dispatched,
169+
is notified. In the above example, when the ``acme.foo.action`` event is dispatched,
170170
the dispatcher calls the ``AcmeListener::onFooAction()`` method and passes
171171
the ``Event`` object as the single argument::
172172

@@ -216,7 +216,7 @@ determine which instance is passed.
216216
// register your event listener service
217217
$listener = new Definition(\AcmeListener::class);
218218
$listener->addTag('kernel.event_listener', array(
219-
'event' => 'foo.action',
219+
'event' => 'acme.foo.action',
220220
'method' => 'onFooAction',
221221
));
222222
$containerBuilder->setDefinition('listener_service_id', $listener);

components/var_dumper.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ This will provide you with two new assertions:
128128

129129
Example::
130130

131-
class ExampleTest extends \PHPUnit_Framework_TestCase
131+
use PHPUnit\Framework\TestCase;
132+
133+
class ExampleTest extends TestCase
132134
{
133135
use \Symfony\Component\VarDumper\Test\VarDumperTestTrait;
134136

console.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ method. Then you can optionally define a help message and the
5050
{
5151
$this
5252
// the name of the command (the part after "app/console")
53-
->setName('app:create-users')
53+
->setName('app:create-user')
5454

5555
// the short description shown while running "php app/console list"
56-
->setDescription('Creates new users.')
56+
->setDescription('Creates a new user.')
5757

5858
// the full command description shown when running the command with
5959
// the "--help" option
60-
->setHelp('This command allows you to create users...')
60+
->setHelp('This command allows you to create a user...')
6161
;
6262
}
6363

@@ -68,7 +68,7 @@ After configuring the command, you can execute it in the terminal:
6868

6969
.. code-block:: terminal
7070
71-
$ php app/console app:create-users
71+
$ php app/console app:create-user
7272
7373
As you might expect, this command will do nothing as you didn't write any logic
7474
yet. Add your own logic inside the ``execute()`` method, which has access to the
@@ -258,7 +258,7 @@ console::
258258

259259
When using the Console component in a standalone project, use
260260
:class:`Symfony\\Component\\Console\\Application <Symfony\\Component\\Console\\Application>`
261-
and extend the normal ``\PHPUnit_Framework_TestCase``.
261+
and extend the normal ``\PHPUnit\Framework\TestCase``.
262262

263263
To be able to use the fully set up service container for your console tests
264264
you can extend your test from

controller.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -424,19 +424,19 @@ read any flash messages from the session:
424424
{# app/Resources/views/base.html.twig #}
425425

426426
{# you can read and display just one flash message type... #}
427-
{% for flash_message in app.session.flash('notice') %}
427+
{% for flash_message in app.session.flashBag.get('notice') %}
428428
<div class="flash-notice">
429429
{{ flash_message }}
430430
</div>
431431
{% endfor %}
432432

433433
{# ...or you can read and display every flash message available #}
434-
{% for type, flash_messages in app.session.flashes %}
434+
{% for type, flash_messages in app.session.flashBag.all %}
435435
{% for flash_message in flash_messages %}
436436
<div class="flash-{{ type }}">
437437
{{ flash_message }}
438438
</div>
439-
{% endif %}
439+
{% endfor %}
440440
{% endfor %}
441441

442442
.. code-block:: html+php

create_framework/http_foundation.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ snippet of PHP code is not natural and feels ugly. Here is a tentative PHPUnit
5858
unit test for the above code::
5959

6060
// framework/test.php
61-
class IndexTest extends \PHPUnit_Framework_TestCase
61+
use PHPUnit\Framework\TestCase;
62+
63+
class IndexTest extends TestCase
6264
{
6365
public function testHello()
6466
{

create_framework/unit_testing.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ We are now ready to write our first test::
7272
// example.com/tests/Simplex/Tests/FrameworkTest.php
7373
namespace Simplex\Tests;
7474

75+
use PHPUnit\Framework\TestCase;
7576
use Simplex\Framework;
7677
use Symfony\Component\HttpFoundation\Request;
7778
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
7879
use Symfony\Component\Routing;
7980
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
8081

81-
class FrameworkTest extends \PHPUnit_Framework_TestCase
82+
class FrameworkTest extends TestCase
8283
{
8384
public function testNotFoundHandling()
8485
{

form/without_class.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ but here's a short example:
102102
If you are using validation groups, you need to either reference the
103103
``Default`` group when creating the form, or set the correct group on
104104
the constraint you are adding.
105+
106+
.. code-block:: php
105107
106-
.. code-block:: php
107-
108-
new NotBlank(array('groups' => array('create', 'update'))
108+
new NotBlank(array('groups' => array('create', 'update')))

testing.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ of your bundle::
7171
namespace AppBundle\Tests\Util;
7272

7373
use AppBundle\Util\Calculator;
74+
use PHPUnit\Framework\TestCase;
7475

75-
class CalculatorTest extends \PHPUnit_Framework_TestCase
76+
class CalculatorTest extends TestCase
7677
{
7778
public function testAdd()
7879
{

testing/database.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ it's easy to pass a mock object within a test::
6363
use AppBundle\Salary\SalaryCalculator;
6464
use Doctrine\ORM\EntityRepository;
6565
use Doctrine\Common\Persistence\ObjectManager;
66+
use PHPUnit\Framework\TestCase;
6667

67-
class SalaryCalculatorTest extends \PHPUnit_Framework_TestCase
68+
class SalaryCalculatorTest extends TestCase
6869
{
6970
public function testCalculateTotalSalary()
7071
{

0 commit comments

Comments
 (0)