Skip to content

Commit 0c11360

Browse files
[VarDumper] Add doc for assertDump* assertions
1 parent d6a838a commit 0c11360

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

components/var_dumper/introduction.rst

+20
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ current PHP SAPI:
7373
#. From time to time, run ``composer global update`` to have the latest
7474
bug fixes.
7575

76+
Using VarDumper in your PHPUnit test suite
77+
------------------------------------------
78+
79+
Since Symfony 2.7, the VarDumper component provides
80+
:class:`a trait <Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait>`
81+
that can help writting some of your tests for PHPUnit.
82+
By adding::
83+
84+
use \Symfony\Component\VarDumper\Test\VarDumperTestTrait;
85+
86+
at the beginning of your test class declaration, you'll gain two new assertions:
87+
88+
:method:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait::assertDumpEquals`
89+
verifies that the dump of the variable given as second argument matches the
90+
expected dump provided as a string in the first argument.
91+
92+
:method:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait::assertDumpMatchesFormat`
93+
is like the previous method but accepts placeholders in the expected dump,
94+
based on the ``assertStringMatchesFormat`` method provided by PHPUnit.
95+
7696
DebugBundle and Twig Integration
7797
--------------------------------
7898

0 commit comments

Comments
 (0)