From 1936f22ec47d2c11218be46ea867d6a0b7d6ec9b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 31 Mar 2015 09:18:05 +0200 Subject: [PATCH] [VarDumper] Add doc for assertDump* assertions --- components/var_dumper/introduction.rst | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/components/var_dumper/introduction.rst b/components/var_dumper/introduction.rst index 05eff3e8849..c864d6ca0c2 100644 --- a/components/var_dumper/introduction.rst +++ b/components/var_dumper/introduction.rst @@ -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 ` +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 --------------------------------