Skip to content

Commit c8d9bad

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

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

components/var_dumper/introduction.rst

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

76+
Using the VarDumper Component in Your PHPUnit Test Suite
77+
--------------------------------------------------------
78+
79+
.. versionadded:: 2.7
80+
The :class:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait` was
81+
introduced in Symfony 2.7.
82+
83+
The VarDumper component provides
84+
:class:`a trait <Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait>`
85+
that can help writting some of your tests for PHPUnit.
86+
You can use it by importing it into your test classes::
87+
88+
class YourTest extends \PHPUnit_Framework_TestCase
89+
{
90+
use \Symfony\Component\VarDumper\Test\VarDumperTestTrait;
91+
92+
// ...
93+
}
94+
95+
This will provide you with two new assertions:
96+
97+
:method:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait::assertDumpEquals`
98+
verifies that the dump of the variable given as the second argument matches
99+
the expected dump provided as a string in the first argument.
100+
101+
:method:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait::assertDumpMatchesFormat`
102+
is like the previous method but accepts placeholders in the expected dump,
103+
based on the ``assertStringMatchesFormat`` method provided by PHPUnit.
104+
105+
.. tip::
106+
107+
If you still use PHP 5.3, you can extend the
108+
:class:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestClass` instead.
109+
76110
DebugBundle and Twig Integration
77111
--------------------------------
78112

0 commit comments

Comments
 (0)