Advertisement
Guest User

Untitled

a guest
Sep 14th, 2013
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.02 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Blogger\BlogBundle\Tests\Controller;
  4.  
  5. use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  6.  
  7. class PageControllerTest extends WebTestCase
  8. {
  9.     public function testAbout()
  10.     {
  11.         $client = static::createClient();
  12.  
  13.         $crawler = $client->request('GET', '/about');
  14.  
  15.         $this->assertEquals(1, $crawler->filter('h1:contains("About symblog")')->count());
  16.     }
  17.  
  18.     public function testIndex()
  19.     {
  20.         $client = static::createClient();
  21.  
  22.         $crawler = $client->request('GET', '/');
  23.  
  24.         // Find the first link, get the title, ensure this is loaded on the next page
  25.         $blogLink   = $crawler->filter('article.blog h2 a')->first();
  26.         $blogTitle  = $blogLink->text();
  27.         $crawler    = $client->click($blogLink->link());
  28.  
  29.         // Check the h2 has the blog title in it
  30.         $this->assertEquals(1, $crawler->filter('h2:contains("' . $blogTitle .'")')->count());
  31.     }
  32.  
  33.     public function testContact()
  34.     {
  35.         $client = static::createClient();
  36.  
  37.         $crawler = $client->request('GET', '/contact');
  38.  
  39.         $this->assertEquals(1, $crawler->filter('h1:contains("Contact symblog")')->count());
  40.  
  41.         // Select based on button value, or id or name for buttons
  42.         $form = $crawler->selectButton('Submit')->form(array(
  43.             'name'=>'name'
  44.         ));
  45. /*
  46.         $form['blogger_blogbundle_enquirytype[name]']       = 'name';
  47.         $form['blogger_blogbundle_enquirytype[email]']      = '[email protected]';
  48.         $form['blogger_blogbundle_enquirytype[subject]']    = 'Subject';
  49.         $form['blogger_blogbundle_enquirytype[body]']       = 'The comment body must be at least 50 characters long as there is a validation constrain on the Enquiry entity';
  50. */
  51.         $crawler = $client->submit($form);
  52.  
  53.         // Need to follow redirect
  54.         $crawler = $client->followRedirect();
  55.  
  56.         $this->assertEquals(1, $crawler->filter('.blogger-notice:contains("Your contact enquiry was successfully sent. Thank you!")')->count());
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement