Skip to content

Commit

Permalink
[VarDumper] Add doc for assertDump* assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Apr 1, 2015
1 parent d6a838a commit 1936f22
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions components/var_dumper/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,35 @@ current PHP SAPI:
#. From time to time, run ``composer global update`` to have the latest
bug fixes.

Using the VarDumper Component in Your PHPUnit Test Suite
--------------------------------------------------------

.. versionadded:: 2.7
The :class:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait` was
introduced in Symfony 2.7.

The VarDumper component provides
:class:`a trait <Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait>`
that can help writting some of your tests for PHPUnit.
You can use it by importing it into your test classes::

class YourTest extends \PHPUnit_Framework_TestCase
{
use \Symfony\Component\VarDumper\Test\VarDumperTestTrait;

// ...
}

This will provide you with two new assertions:

:method:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait::assertDumpEquals`
verifies that the dump of the variable given as the second argument matches
the expected dump provided as a string in the first argument.

:method:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait::assertDumpMatchesFormat`
is like the previous method but accepts placeholders in the expected dump,
based on the ``assertStringMatchesFormat`` method provided by PHPUnit.

DebugBundle and Twig Integration
--------------------------------

Expand Down

0 comments on commit 1936f22

Please sign in to comment.