diff --git a/src/Blogger/BlogBundle/Tests/Controller/BlogControllerTest.php b/src/Blogger/BlogBundle/Tests/Controller/BlogControllerTest.php new file mode 100644 index 0000000..e24677a --- /dev/null +++ b/src/Blogger/BlogBundle/Tests/Controller/BlogControllerTest.php @@ -0,0 +1,46 @@ +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() + ); + } +} \ No newline at end of file