@@ -112,6 +112,11 @@ widgets you want to display are available in the children property::
112112 $this->assertArrayHasKey($key, $children);
113113 }
114114
115+ .. tip ::
116+
117+ Use :ref: `PHPUnit data providers <testing-data-providers >` to test multiple
118+ form conditions using the same test code.
119+
115120Testings Types from the Service Container
116121-----------------------------------------
117122
@@ -212,56 +217,3 @@ allows you to return a list of extensions to register::
212217
213218 // ... your tests
214219 }
215-
216- Testing against Different Sets of Data
217- --------------------------------------
218-
219- If you are not familiar yet with PHPUnit's `data providers `_, this might be
220- a good opportunity to use them::
221-
222- // src/AppBundle/Tests/Form/Type/TestedTypeTest.php
223- namespace AppBundle\Tests\Form\Type;
224-
225- use AppBundle\Form\Type\TestedType;
226- use Symfony\Component\Form\Test\TypeTestCase;
227-
228- class TestedTypeTest extends TypeTestCase
229- {
230- /**
231- * @dataProvider getValidTestData
232- */
233- public function testForm($data)
234- {
235- // ... your test
236- }
237-
238- public function getValidTestData()
239- {
240- return array(
241- array(
242- 'data' => array(
243- 'test' => 'test',
244- 'test2' => 'test2',
245- ),
246- ),
247- array(
248- 'data' => array(),
249- ),
250- array(
251- 'data' => array(
252- 'test' => null,
253- 'test2' => null,
254- ),
255- ),
256- );
257- }
258- }
259-
260- The code above will run your test three times with 3 different sets of
261- data. This allows for decoupling the test fixtures from the tests and
262- easily testing against multiple sets of data.
263-
264- You can also pass another argument, such as a boolean if the form has to
265- be synchronized with the given set of data or not etc.
266-
267- .. _`data providers` : https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers
0 commit comments