/**
  * Do login with username
  *
  * @param string $username
  */
 private function doLogin($username = '******')
 {
     $crawler = $this->client->request('GET', $this->getUrl('fos_user_security_login', array()));
     $form = $crawler->selectButton('_submit')->form(array('_username' => $username, '_password' => 'qwerty'));
     $this->client->submit($form);
     $this->assertTrue($this->client->getResponse()->isRedirect());
     $this->client->followRedirects();
 }
示例#2
0
 /**
  * Log into the application using a provided username and password.
  * @param string $username
  * @param string $password
  * @return Crawler
  */
 public function login($username, $password)
 {
     $crawler = $this->client->request('GET', $this->profileUrl);
     $form = $crawler->selectButton('_submit')->form();
     $form['_username'] = $username;
     $form['_password'] = $password;
     $crawler = $this->client->submit($form);
     return $crawler;
 }
 /**
  * Отображение ошибки при ответе
  */
 public function testTicketReplyErrors()
 {
     $crawler = $this->client->request('GET', '/ticket/6/show?_locale=ru');
     $form = $crawler->selectButton('Message[submit]')->form();
     $crawler = $this->client->submit($form);
     static::assertGreaterThan(0, $crawler->filter('html:contains("Заполните поле Сообщение или загрузите изображение")')->count());
 }
 public function testLogout()
 {
     $this->authorize();
     $listUrl = $this->urlGenerator->generate('list', ['bucket' => 'foo']);
     $this->s3ClientMock->expects($this->once())->method('listBuckets')->willReturn(new Result([]));
     $this->s3ClientMock->expects($this->once())->method('listObjects')->willReturn(new Result([]));
     $crawler = $this->client->request('GET', $listUrl);
     $this->assertTrue($this->client->getResponse()->isOk());
     $form = $crawler->filter('#form-logout')->form();
     $this->client->submit($form);
     $this->assertTrue($this->client->getResponse()->isRedirect('http://localhost' . $listUrl));
     $cookies = $this->client->getResponse()->headers->getCookies();
     $this->assertCount(1, $cookies);
     $this->assertEquals($this->app['amazon_s3_credentials_cookie_name'], $cookies[0]->getName());
     $this->assertNull($cookies[0]->getValue());
 }
 /**
  * @param string $username
  * @param string $password
  */
 protected function submitLoginForm($username, $password)
 {
     $this->loginForm[self::USERNAME_FIELD] = $username;
     $this->loginForm[self::PASSWORD_FIELD] = $password;
     $this->crawler = $this->client->submit($this->loginForm);
 }