-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Provide full test example #4712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,25 +30,34 @@ 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); | ||
<?php | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should remove this line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope the empty line after the line you mentioned There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
} | ||
namespace AppBundle\Tests; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please add a file comment: |
||
|
||
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 provideUrls */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would actually like to have this as a "real" docblock: /**
* @dataProvider provideUrls
*/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, me too. |
||
public function testPageIsSuccessful($url) | ||
{ | ||
$client = self::createClient(); | ||
$client->request('GET', $url); | ||
|
||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
} | ||
|
||
public function provideUrls() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would like to rename this to UrlProvider, this would be consistent with the PHPUnit manual There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this naming is fine (I always use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think both |
||
{ | ||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should remove the open tag, we never use it in the docs.