- $crawler = $client->request('GET', '/login');
-
- $form = $crawler->filter('button[type=submit]')->form();
- $data = array(
- '_username' => 'admin',
- '_password' => 'admin',
- );
-
- $client->submit($form, $data);
-
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
- $this->assertContains('login', $client->getResponse()->headers->get('location'));
-
- $crawler = $client->followRedirect();
-
- $this->assertContains('Bad credentials', $client->getResponse()->getContent());
- }
-
- public function testForgotPassword()
- {
- $client = $this->getClient();
-
- $crawler = $client->request('GET', '/forgot-password');
-
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
-
- $this->assertContains('Forgot password', $client->getResponse()->getContent());
-
- $form = $crawler->filter('button[type=submit]');
-
- $this->assertCount(1, $form);
-
- return array(
- 'form' => $form->form(),
- 'client' => $client,
- );
- }
-
- /**
- * @depends testForgotPassword
- */
- public function testSubmitForgotPasswordFail($parameters)
- {
- $form = $parameters['form'];
- $client = $parameters['client'];
-
- $data = array(
- 'forgot_password[email]' => 'material',
- );
-
- $client->submit($form, $data);
-
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertContains('No user found with this email', $client->getResponse()->getContent());
- }
-
- /**
- * @depends testForgotPassword
- *
- * Instead of using collector which slow down the test suite
- * http://symfony.com/doc/current/cookbook/email/testing.html
- *
- * Use a different way where Swift store email as file
- */
- public function testSubmitForgotPassword($parameters)
- {
- $form = $parameters['form'];
- $client = $parameters['client'];