Skip to content

Commit d4ab971

Browse files
committed
Provide full test example
In my opinion providing the full code for the example only adds a few additional lines, but increases the value of the example greatly. Of course the name for the test should probably be changed as couldn't think of a good one. ping @stof | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3 | Fixed tickets |
1 parent 153565e commit d4ab971

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

best_practices/tests.rst

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,34 @@ A functional test can be as easy as this:
3030

3131
.. code-block:: php
3232
33-
/** @dataProvider provideUrls */
34-
public function testPageIsSuccessful($url)
35-
{
36-
$client = self::createClient();
37-
$client->request('GET', $url);
33+
<?php
3834
39-
$this->assertTrue($client->getResponse()->isSuccessful());
40-
}
35+
namespace AppBundle\Tests;
36+
37+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
4138
42-
public function provideUrls()
39+
class ApplicationAvailabilityFunctionalTest extends WebTestCase
4340
{
44-
return array(
45-
array('/'),
46-
array('/posts'),
47-
array('/post/fixture-post-1'),
48-
array('/blog/category/fixture-category'),
49-
array('/archives'),
50-
// ...
51-
);
41+
/** @dataProvider provideUrls */
42+
public function testPageIsSuccessful($url)
43+
{
44+
$client = self::createClient();
45+
$client->request('GET', $url);
46+
47+
$this->assertTrue($client->getResponse()->isSuccessful());
48+
}
49+
50+
public function provideUrls()
51+
{
52+
return array(
53+
array('/'),
54+
array('/posts'),
55+
array('/post/fixture-post-1'),
56+
array('/blog/category/fixture-category'),
57+
array('/archives'),
58+
// ...
59+
);
60+
}
5261
}
5362
5463
This code checks that all the given URLs load successfully, which means that

0 commit comments

Comments
 (0)