fixing minor issues and adding unit test

This commit is contained in:
Amine Ben hammou
2017-12-26 15:21:16 +00:00
parent 1ad0dce425
commit a8052c118a
8 changed files with 39 additions and 23 deletions

View File

@ -461,6 +461,19 @@ class SubscribersTest extends \MailPoetTest {
expect($response->status)->equals(APIResponse::STATUS_OK);
}
function testItCannotSubscribeWithoutCaptchaWhenEnabled() {
Setting::setValue('re_captcha', array('enabled' => true));
$router = new Subscribers();
$response = $router->subscribe(array(
$this->obfuscatedEmail => 'toto@mailpoet.com',
'form_id' => $this->form->id,
$this->obfuscatedSegments => array($this->segment_1->id, $this->segment_2->id)
));
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals('Please check the captcha.');
Setting::setValue('re_captcha', array());
}
function testItCanSubscribeWithoutSegmentsIfTheyAreSelectedByAdmin() {
$form = $this->form->asArray();
$form['settings']['segments_selected_by'] = 'admin';