diff --git a/console.rst b/console.rst index 30cd2dfb84a..cada5d73bba 100644 --- a/console.rst +++ b/console.rst @@ -216,21 +216,16 @@ console:: namespace Tests\AppBundle\Command; use AppBundle\Command\CreateUserCommand; - use Symfony\Component\Console\Application; - // use this if you're in the Symfony Framework - //use Symfony\Bundle\FrameworkBundle\Console\Application; + use Symfony\Bundle\FrameworkBundle\Console\Application; + use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Console\Tester\CommandTester; - class CreateUserCommandTest extends \PHPUnit_Framework_TestCase + class CreateUserCommandTest extends KernelTestCase { public function testExecute() { - $application = new Application(); - - // if you're in the Symfony framework, do this instead - // extend the KernelTestCase class - // self::bootKernel(); - // $application = new Application(self::$kernel); + self::bootKernel(); + $application = new Application(self::$kernel); $application->add(new CreateUserCommand()); @@ -259,6 +254,12 @@ console:: You can also test a whole console application by using :class:`Symfony\\Component\\Console\\Tester\\ApplicationTester`. +.. note:: + + When using the Console component in a standalone project, use + :class:`Symfony\\Component\\Console\\Application ` + and extend the normal ``\PHPUnit_Framework_TestCase``. + To be able to use the fully set up service container for your console tests you can extend your test from :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase`:: diff --git a/contributing/documentation/overview.rst b/contributing/documentation/overview.rst index b955583121f..be264b0e2fd 100644 --- a/contributing/documentation/overview.rst +++ b/contributing/documentation/overview.rst @@ -261,10 +261,10 @@ link displayed for Platform.sh service. Build the Documentation Locally ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Alternatively you can build the documentation in your own computer for testing +Alternatively you can build the documentation on your own computer for testing purposes following these steps: -#. Install `pip`_ as explained in the `pip installation`_ article. +#. Install `pip`_ as explained in the `pip installation`_ article; #. Install `Sphinx`_ and `Sphinx Extensions for PHP and Symfony`_ (depending on your system, you may need to execute this command as root user): diff --git a/routing.rst b/routing.rst index f4e5a4c47f3..b6440dacc5d 100644 --- a/routing.rst +++ b/routing.rst @@ -256,13 +256,13 @@ expressions - see :doc:`/routing/requirements`. Giving {placeholders} a Default Value ------------------------------------- -In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If the -user goes to ``/blog/1``, it will match. But if the user goes to ``/blog``, it will -**not** match. As soon as you add a ``{placeholder}`` to a route, it *must* have -a value. +In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If +the user visits ``/blog/1``, it will match. But if they visit ``/blog``, it +will **not** match. As soon as you add a ``{placeholder}`` to a route, it +*must* have a value. -So how can we make ``/blog_list`` once again match when the user goes to ``/blog``? -By adding a *default* value: +So how can you make ``blog_list`` once again match when the user visits +``/blog``? By adding a *default* value: .. configuration-block:: @@ -309,6 +309,7 @@ By adding a *default* value: AppBundle:Blog:list 1 + \d+ @@ -322,19 +323,23 @@ By adding a *default* value: use Symfony\Component\Routing\Route; $collection = new RouteCollection(); - $collection->add('blog_list', new Route('/blog/{page}', array( - '_controller' => 'AppBundle:Blog:list', - 'page' => 1, - ), array( - 'page' => '\d+' - ))); + $collection->add('blog_list', new Route( + '/blog/{page}', + array( + '_controller' => 'AppBundle:Blog:list', + 'page' => 1, + ), + array( + 'page' => '\d+' + ) + )); // ... return $collection; -Now, when the user goes to ``/blog``, the ``blog_list`` route will match and ``$page`` -will default to a value of ``1``. +Now, when the user visits ``/blog``, the ``blog_list`` route will match and +``$page`` will default to a value of ``1``. .. index:: single: Routing; Advanced example diff --git a/templating.rst b/templating.rst index ba39052cd74..51ee7ec7a45 100644 --- a/templating.rst +++ b/templating.rst @@ -109,7 +109,7 @@ with alternating ``odd``, ``even`` classes: .. code-block:: html+twig {% for i in 1..10 %} -
+
{% endfor %}