Add integration tests [MAILPOET-2015]

This commit is contained in:
wxa
2019-07-04 20:20:06 +03:00
committed by M. Shull
parent b174a55d07
commit d36c9b44e4
6 changed files with 161 additions and 4 deletions

View File

@ -3,6 +3,8 @@ namespace MailPoet\Test\Subscription;
use Codeception\Stub;
use MailPoet\API\JSON\API;
use MailPoet\API\JSON\ErrorResponse;
use MailPoet\API\JSON\Response;
use MailPoet\DI\ContainerWrapper;
use MailPoet\Form\Util\FieldNameObfuscator;
use MailPoet\Models\Form as FormModel;
@ -120,6 +122,23 @@ class FormTest extends \MailPoetTest {
expect($result['mailpoet_success'])->null();
}
function testItDoesNotSubscribeAndRedirectsToRedirectUrlIfPresent() {
$redirect_url = 'http://test/';
$url_helper = Stub::make(UrlHelper::class, [
'redirectTo' => function($params) {
return $params;
},
], $this);
$api = Stub::makeEmpty(API::class, [
'processRoute' => function() use ($redirect_url) {
return new ErrorResponse([], ['redirect_url' => $redirect_url], Response::STATUS_BAD_REQUEST);
},
], $this);
$form_controller = new Form($api, $url_helper);
$result = $form_controller->onSubmit($this->request_data);
expect($result)->equals($redirect_url);
}
function _after() {
wp_delete_post($this->post);
\ORM::raw_execute('TRUNCATE ' . SegmentModel::$_table);