Browse files

tests + missing routing config

  • Loading branch information...
1 parent a6c57ad commit 112825a7d383eaf2f3a171642af400b6897a4df7 @smottt committed Mar 5, 2012
View
14 src/PHP/NewsBundle/Resources/config/routing.yml
@@ -0,0 +1,14 @@
+news_list:
+ pattern: /novice/{page}
+ defaults: { _controller: PHPNewsBundle:Default:list, page: 1 }
+ requirements:
+ page: \d+
+ _method: GET
+
+news_show:
+ pattern: /novica/{id}/{page}
+ defaults: { _controller: PHPNewsBundle:Default:show, page: 1 }
+ requirements:
+ id: \d+
+ page: \d+
+ _method: GET
View
51 src/PHP/NewsBundle/Tests/Controller/DefaultControllerTest.php
@@ -6,12 +6,51 @@
class DefaultControllerTest extends WebTestCase
{
- public function testIndex()
- {
- $client = static::createClient();
+ private $client;
- $crawler = $client->request('GET', '/hello/Fabien');
+ public function setUp()
+ {
+ $this->client = static::createClient();
+ }
- $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
- }
+ public function testList()
+ {
+ // default page
+ $this->client->request('GET', '/novice');
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ // random page
+ $this->client->request('GET', '/novice/2');
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ // non-existent page
+ $this->client->request('GET', '/novice/1024');
+
+ $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+ }
+
+ public function testShow()
+ {
+ // random page, default comment page
+ $this->client->request('GET', '/novica/1');
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ // non-existent page
+ $this->client->request('GET', '/novice/1024');
+
+ $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+
+ // random page, random comment page
+ $this->client->request('GET', '/novica/3/2');
+
+ $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+ // non-existent page, non-existent comment page
+ $this->client->request('GET', '/novica/1024/1024');
+
+ $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+ }
}

0 comments on commit 112825a

Please sign in to comment.