/**
  * @dataProvider provideLoginData
  */
 public function testLogin(Client $client, $securedUrl, $login, $expectedMessage)
 {
     // client follow redirects
     $client->followRedirects();
     // go to secured page -> got login required
     $crawler = $client->request('GET', $securedUrl);
     $this->assertEquals(TrustedSsoController::LOGIN_REQUIRED_MESSAGE, $crawler->filter('#message')->text());
     // click link -> got login form
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals('login', $crawler->filter('form')->attr('id'));
     // fill form & submit -> got expected message
     $form = $crawler->filter('input[type=submit]')->form();
     $crawler = $client->submit($form, array('login[username]' => $login, 'login[password]' => $login));
     $this->assertEquals($expectedMessage, $crawler->filter('#message')->text());
     if (!$login === self::LOGIN_INVALID) {
         // check validation attributes
         $attrs = static::$kernel->getContainer()->get('security.context')->getToken()->getValidationAttributes();
         $this->assertEquals(array('attr1' => 'val1', 'attr2' => 'val2'), $attrs);
     }
     // logout -> got logout redirect
     $crawler = $client->request('GET', '/secured/logout');
     $this->assertEquals(TrustedSsoController::LOGOUT_REDIRECT_MESSAGE, $crawler->filter('#message')->text());
     // click link -> got logout done
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals(ServerController::LOGOUT_MESSAGE, $crawler->filter('#message')->text());
     // click link -> go to homepage
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals(TestController::HOME_MESSAGE, $crawler->filter('#message')->text());
 }
 public function testOut()
 {
     $this->client->request('GET', '/');
     $crawler = $this->client->followRedirect();
     $link = $crawler->filter('a#logout')->eq(0)->link();
     $this->client->click($link);
     //suivre redirection vers page login quand click sur 'logout'
     $this->assertEquals('Sonata\\UserBundle\\Controller\\SecurityFOSUser1Controller::logoutAction', $this->client->getRequest()->attributes->get('_controller'));
     $this->assertEquals(302, $this->client->getResponse()->getStatusCode());
 }
Example #3
0
 public function testEdit()
 {
     $crawler = $this->client->request('GET', '/member');
     $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
     $this->assertEquals(1, $crawler->filter('div.app_member_index')->count());
     $this->assertGreaterThanOrEqual(1, $crawler->selectLink('Show')->count());
     $crawler = $this->client->click($crawler->selectLink('Show')->first()->link());
     $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
     $this->assertEquals(1, $crawler->filter('div.app_member_show')->count());
     $this->assertGreaterThanOrEqual(1, $crawler->selectLink('Edit')->count());
     $crawler = $this->client->click($crawler->selectLink('Edit')->first()->link());
     $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
     $this->assertEquals(1, $crawler->filter('div.app_member_edit')->count());
 }
Example #4
0
 /**
  * Performs logout action and returns same client after log out.
  *
  * @param Client $client
  *
  * @return Client
  */
 public function logoutAction(Client $client)
 {
     $crawler = $client->request('GET', '/settings/login');
     $link = $crawler->filter('a:contains("Logout")')->link();
     $client->click($link);
     return $client;
 }
Example #5
0
 /**
  * @param Crawler $crawler
  * @return boolean|Crawler
  * TODO: Поиск записей по всем доступным страницам.
  */
 protected function pagination(Crawler $crawler)
 {
     $nextPageCrawler = $crawler->selectLink('След.');
     if ($nextPageCrawler && $nextPageCrawler->getNode(0) && false === mb_stripos($nextPageCrawler->getNode(0)->getAttribute('class'), 'ui-disabled', null, 'UTF-8')) {
         return self::$client->click($nextPageCrawler->link());
     }
     return false;
 }
 public function testPreviewOwner()
 {
     $pageEleveur = $this->testUtils->createUser()->toEleveur()->getPageEleveur();
     $crawler = $this->client->request('GET', '/elevage/' . $pageEleveur->getSlug());
     $this->assertContains(self::FLAG_JS_EDITABLE, $crawler->html());
     $previewLink = $crawler->filter('#eleveur-toolbar #preview')->link();
     $crawnlerPreview = $this->client->click($previewLink);
     $this->assertNotContains(self::FLAG_JS_EDITABLE, $crawnlerPreview->html());
 }
 public function testLinkContact()
 {
     $crawler = $this->client->request('GET', '/');
     $this->client->click($crawler->filter('footer a[href="/contact"]')->link());
     $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
 }
 /**
  * Moves forward to the summary page
  *
  * @param \Symfony\Bundle\FrameworkBundle\Client $client HTTP test client
  * @return \Symfony\Component\DomCrawler\Crawler Crawler HTTP crawler
  */
 protected function _goToSummary($client)
 {
     $crawler = $client->request('GET', '/unittest/de/EUR/list');
     $link = $crawler->filter('.catalog-list-items .product a:contains("Unittest: Bundle")')->link();
     $crawler = $client->click($link);
     $form = $crawler->filter('.catalog-detail .addbasket .btn-action')->form();
     $crawler = $client->submit($form);
     $link = $crawler->filter('.basket-standard .btn-action')->link();
     $crawler = $client->click($link);
     $form = $crawler->filter('.checkout-standard form')->form();
     $form['ca_billingoption']->select($crawler->filter('.checkout-standard-address .item-address input')->attr('value'));
     $crawler = $client->submit($form);
     $form = $crawler->filter('.checkout-standard form')->form();
     $form['c_deliveryoption']->select($crawler->filter('.checkout-standard-delivery .item-service input')->attr('value'));
     $crawler = $client->submit($form);
     $form = $crawler->filter('.checkout-standard form')->form();
     $form['c_paymentoption']->select($crawler->filter('.checkout-standard-payment .item-service input')->attr('value'));
     $crawler = $client->submit($form);
     return $crawler;
 }
 public function testLogIn()
 {
     $link = $this->crawler->filter('a:contains("Zaloguj się")')->link();
     $log = $this->client->click($link);
     $this->assertContains("Formularz logowania", $log->filter('.container h1')->text());
 }
 /**
  * Clicks on a given link.
  *
  * @param Link $link A Link instance
  *
  * @return Crawler
  *
  * @api
  */
 public function click(Link $link)
 {
     return $this->subject->click($link);
 }