10000 Merge branch '2.8' into 3.4 · symfony/symfony-docs@6f6b216 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f6b216

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Updated the command to run the Docker image [Doctrine Bridge] document priority for doctrine.event_listener tag Add details on how the ClockMock::register works Add Dockerfile Fix function name in expression
2 parents ad91c78 + 9af277c commit 6f6b216

File tree

5 files changed

+127
-1
lines changed

5 files changed

+127
-1
lines changed

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:2-stretch as builder
2+
3+
WORKDIR /www
4+
5+
COPY ./_build/.requirements.txt _build/
6+
7+
RUN pip install pip==9.0.1 wheel==0.29.0 \
8+
&& pip install -r _build/.requirements.txt
9+
10+
COPY . /www
11+
12+
RUN make -C _build html
13+
14+
FROM nginx:latest
15+
16+
COPY --from=builder /www/_build/html /usr/share/nginx/html

README.markdown

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,17 @@ Platform.sh
1919
-----------
2020

2121
Pull requests are automatically built by [Platform.sh](https://platform.sh).
22+
23+
Docker
24+
------
25+
26+
You can build the doc locally with these commands:
27+
28+
```bash
29+
# build the image...
30+
$ docker build . -t symfony-docs
31+
32+
# ...and serve it locally on http//:127.0.0.1:8080
33+
# (if it's already in use, change the '8080' port by any other port)
34+
$ docker run --rm -p 8080:80 symfony-docs
35+
```

components/phpunit_bridge.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,48 @@ test::
352352

353353
And that's all!
354354

355+
.. caution::
356+
357+
Time-based function mocking follows the `PHP namespace resolutions rules`_
358+
so "fully qualified function calls" (e.g ``\time()``) cannot be mocked.
359+
360+
The ``@group time-sensitive`` annotation is equivalent to calling
361+
``ClockMock::register(MyTest::class)``. If you want to mock a function used in a
362+
different class, do it explicitly using ``ClockMock::register(MyClass::class)``::
363+
364+
// the class that uses the time() function to be mocked
365+
namespace App;
366+
367+
class MyClass
368+
{
369+
public function getTimeInHours()
370+
{
371+
return time() / 3600;
372+
}
373+
}
374+
375+
// the test that mocks the external time() function explicitly
376+
namespace App\Tests;
377+
378+
use App\MyClass;
379+
use PHPUnit\Framework\TestCase;
380+
381+
/**
382+
* @group time-sensitive
383+
*/
384+
class MyTest extends TestCase
385+
{
386+
public function testGetTimeInHours()
387+
{
388+
ClockMock::register(MyClass::class);
389+
390+
$my = new MyClass();
391+
$result = $my->getTimeInHours();
392+
393+
$this->assertEquals(time() / 3600, $result);
394+
}
395+
}
396+
355397
.. tip::
356398

357399
An added bonus of using the ``ClockMock`` class is that time passes
@@ -631,3 +673,4 @@ not find the SUT:
631673
.. _`Travis CI`: https://travis-ci.org/
632674
.. _`test listener`: https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.test-listeners
633675
.. _`@covers`: https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.covers
676+
.. _`PHP namespace resolutions rules`: https://php.net/manual/en/language.namespaces.rules.php

doctrine/event_listeners_subscribers.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,56 @@ to the tag like so:
242242

243243
.. _`The Event System`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
244244
.. _`the Doctrine Documentation`: https://symfony.com/doc/current/bundles/DoctrineBundle/entity-listeners.html
245+
246+
Priorities for Event Listeners
247+
------------------------------
248+
249+
In case you have multiple listeners for the same event you can control the order
250+
in which they are invoked using the ``priority`` attribute on the tag.
251+
Listeners with a higher priority are invoked first.
252+
253+
.. configuration-block::
254+
255+
.. code-block:: yaml
256+
257+
services:
258+
my.listener.with_high_priority:
259+
class: AppBundle\EventListener\MyHighPriorityListener
260+
tags:
261+
- { name: doctrine.event_listener, event: postPersist, priority: 10 }
262+
263+
my.listener.with_low_priority:
264+
class: AppBundle\EventListener\MyLowPriorityListener
265+
tags:
266+
- { name: doctrine.event_listener, event: postPersist, priority: 1 }
267+
268+
.. code-block:: xml
269+
270+
<?xml version="1.0" ?>
271+
<container xmlns="http://symfony.com/schema/dic/services"
272+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine">
273+
274+
<services>
275+
<service id="my.listener.with_high_priority" class="AppBundle\EventListener\MyHighPriorityListener">
276+
<tag name="doctrine.event_listener" event="postPersist" priority="10" />
277+
</service>
278+
<service id="my.listener.with_low_priority" class="AppBundle\EventListener\MyLowPriorityListener">
279+
<tag name="doctrine.event_listener" event="postPersist" priority="1" />
280+
</service>
281+
</services>
282+
</container>
283+
284+
.. code-block:: php
285+
286+
use AppBundle\EventListener\MyHighPriorityListener;
287+
use AppBundle\EventListener\MyLowPriorityListener;
288+
289+
$container
290+
->register('my.listener.with_high_priority', MyHighPriorityListener::class)
291+
->addTag('doctrine.event_listener', array('event' => 'postPersist', 'priority' => 10))
292+
;
293+
294+
$container
295+
->register('my.listener.with_low_priority', MyLowPriorityListener::class)
296+
->addTag('doctrine.event_listener', array('event' => 'postPersist', 'priority' => 1))
297+
;

security/expressions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Additionally, you have access to a number of functions inside the expression:
6767

6868
.. sidebar:: ``is_remember_me`` is different than checking ``IS_AUTHENTICATED_REMEMBERED``
6969

70-
The ``is_remember_me()`` and ``is_authenticated_fully()`` functions are *similar*
70+
The ``is_remember_me()`` and ``is_fully_authenticated()`` functions are *similar*
7171
to using ``IS_AUTHENTICATED_REMEMBERED`` and ``IS_AUTHENTICATED_FULLY``
7272
with the ``isGranted()`` function - but they are **not** the same. The
7373
following shows the difference::

0 commit comments

Comments
 (0)
0