forked from dsyph3r/symblog
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/Blogger/BlogBundle/Tests/Controller/BlogControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Blogger\BlogBundle\Tests\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
class BlogControllerTest extends WebTestCase | ||
{ | ||
public function testAddBlogComment() | ||
{ | ||
$client = static::createClient(); | ||
|
||
$crawler = $client->request('GET', '/1/a-day-with-symfony'); | ||
|
||
$this->assertEquals(1, $crawler->filter('h2:contains("A day with Symfony2")')->count()); | ||
|
||
// Select based on button value, or id or name for buttons | ||
$form = $crawler->selectButton('Submit')->form(); | ||
|
||
$crawler = $client->submit($form, array( | ||
'blogger_blogbundle_commenttype[user]' => 'name', | ||
'blogger_blogbundle_commenttype[comment]' => 'comment', | ||
)); | ||
|
||
// Need to follow redirect | ||
$crawler = $client->followRedirect(); | ||
|
||
// Check comment is now displaying on page, as the last entry. This ensure comments | ||
// are posted in order of oldest to newest | ||
$articleCrawler = $crawler->filter('section .previous-comments article')->last(); | ||
|
||
$this->assertEquals('name', $articleCrawler->filter('header span.highlight')->text()); | ||
$this->assertEquals('comment', $articleCrawler->filter('p')->last()->text()); | ||
|
||
// Check the sidebar to ensure latest comments are display and there is 10 of them | ||
|
||
$this->assertEquals(10, $crawler->filter('aside.sidebar section')->last() | ||
->filter('article')->count() | ||
); | ||
|
||
$this->assertEquals('name', $crawler->filter('aside.sidebar section')->last() | ||
->filter('article')->first() | ||
->filter('header span.highlight')->text() | ||
); | ||
} | ||
} |