Fix unit tests

This commit is contained in:
Romain Neutron
2013-01-29 19:35:51 +01:00
parent 00ea1c4c25
commit 74ce48fe45
5 changed files with 20 additions and 4 deletions

View File

@@ -183,7 +183,7 @@ class Dashboard implements ControllerProviderInterface
$app->abort(400, 'Bad request missing email parameter');
};
if (\Swift_Validate::email($request->request->get('email'))) {
if (!\Swift_Validate::email($request->request->get('email'))) {
$app->abort(400, 'Bad request missing email parameter');
};

View File

@@ -309,6 +309,8 @@ class Account implements ControllerProviderInterface
$mail->setButtonUrl($url);
$mail->setExpiration($date);
$app['notification.deliverer']->deliver($mail);
return $app->redirect('/account/reset-email/?update=mail-send');
}

View File

@@ -86,7 +86,7 @@ class caption_Field_Value implements cache_cacheableInterface
$this->VocabularyId = $datas['vocabularyId'];
return $this;
} catch (\InvalidArgumentException $e) {
} catch (\Exception $e) {
}

View File

@@ -57,13 +57,27 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailTest');
self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/', array(
'email' => self::$DI['user']->get_email()
'email' => 'user-test@phraseanet.com'
));
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegexp('/email=/', self::$DI['client']->getResponse()->headers->get('location'));
}
/**
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::sendMail
*/
public function testSendMailTestWithWrongMail()
{
$this->setAdmin(true);
self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/', array(
'email' => 'user-test-phraseanet.com'
));
$this->assertEquals(400, self::$DI['client']->getResponse()->getStatusCode());
}
/**
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::sendMail
*/

View File

@@ -181,7 +181,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect());
$this->assertEquals('/login/forgot-password/?error=invalidmail', $response->headers->get('location'));
$this->assertEquals('/login/forgot-password/?error=noaccount', $response->headers->get('location'));
}
/**