Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions best_practices/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,35 @@ A functional test can be as easy as this:

.. code-block:: php

/** @dataProvider provideUrls */
public function testPageIsSuccessful($url)
{
$client = self::createClient();
$client->request('GET', $url);
// src/AppBundle/Tests/ApplicationAvailabilityFunctionalTest.php
namespace AppBundle\Tests;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add a file comment: // src/AppBundle/Tests/ApplicationAvailabilityFunctionalTest.php ?


$this->assertTrue($client->getResponse()->isSuccessful());
}
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

public function provideUrls()
class ApplicationAvailabilityFunctionalTest extends WebTestCase
{
return array(
array('/'),
array('/posts'),
array('/post/fixture-post-1'),
array('/blog/category/fixture-category'),
array('/archives'),
// ...
);
/**
* @dataProvider urlProvider
*/
public function testPageIsSuccessful($url)
{
$client = self::createClient();
$client->request('GET', $url);

$this->assertTrue($client->getResponse()->isSuccessful());
}

public function urlProvider()
{
return array(
array('/'),
array('/posts'),
array('/post/fixture-post-1'),
array('/blog/category/fixture-category'),
array('/archives'),
// ...
);
}
}

This code checks that all the given URLs load successfully, which means that
Expand Down