Fix tests
[MAILPOET-2378]
This commit is contained in:
committed by
Jack Kitterhing
parent
0bd46d72e0
commit
51284bc883
@@ -3,6 +3,7 @@
|
|||||||
namespace MailPoet\Subscription;
|
namespace MailPoet\Subscription;
|
||||||
|
|
||||||
use MailPoet\API\JSON\API;
|
use MailPoet\API\JSON\API;
|
||||||
|
use MailPoet\API\JSON\Endpoint;
|
||||||
use MailPoet\API\JSON\Response as APIResponse;
|
use MailPoet\API\JSON\Response as APIResponse;
|
||||||
use MailPoet\Util\Url as UrlHelper;
|
use MailPoet\Util\Url as UrlHelper;
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ class Form {
|
|||||||
|
|
||||||
function onSubmit($request_data = false) {
|
function onSubmit($request_data = false) {
|
||||||
$request_data = ($request_data) ? $request_data : $_REQUEST;
|
$request_data = ($request_data) ? $request_data : $_REQUEST;
|
||||||
$this->api->setRequestData($request_data);
|
$this->api->setRequestData($request_data, Endpoint::TYPE_POST);
|
||||||
$form_id = (!empty($request_data['data']['form_id'])) ? (int)$request_data['data']['form_id'] : false;
|
$form_id = (!empty($request_data['data']['form_id'])) ? (int)$request_data['data']['form_id'] : false;
|
||||||
$response = $this->api->processRoute();
|
$response = $this->api->processRoute();
|
||||||
if ($response->status !== APIResponse::STATUS_OK) {
|
if ($response->status !== APIResponse::STATUS_OK) {
|
||||||
|
@@ -5,6 +5,7 @@ namespace MailPoet\Test\API\JSON;
|
|||||||
use Codeception\Stub;
|
use Codeception\Stub;
|
||||||
use Codeception\Stub\Expected;
|
use Codeception\Stub\Expected;
|
||||||
use MailPoet\API\JSON\API as JSONAPI;
|
use MailPoet\API\JSON\API as JSONAPI;
|
||||||
|
use MailPoet\API\JSON\Endpoint;
|
||||||
use MailPoet\API\JSON\Response;
|
use MailPoet\API\JSON\Response;
|
||||||
use MailPoet\API\JSON\Response as APIResponse;
|
use MailPoet\API\JSON\Response as APIResponse;
|
||||||
use MailPoet\API\JSON\SuccessResponse;
|
use MailPoet\API\JSON\SuccessResponse;
|
||||||
@@ -96,7 +97,7 @@ class APITest extends \MailPoetTest {
|
|||||||
'method' => 'test',
|
'method' => 'test',
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->api->setRequestData($data);
|
$response = $this->api->setRequestData($data, Endpoint::TYPE_POST);
|
||||||
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ class APITest extends \MailPoetTest {
|
|||||||
'api_version' => 'v2',
|
'api_version' => 'v2',
|
||||||
'method' => 'test',
|
'method' => 'test',
|
||||||
];
|
];
|
||||||
$this->api->setRequestData($data);
|
$this->api->setRequestData($data, Endpoint::TYPE_POST);
|
||||||
|
|
||||||
expect($this->api->getRequestedAPIVersion())->equals('v2');
|
expect($this->api->getRequestedAPIVersion())->equals('v2');
|
||||||
expect($this->api->getRequestedEndpointClass())->equals(
|
expect($this->api->getRequestedEndpointClass())->equals(
|
||||||
@@ -133,7 +134,7 @@ class APITest extends \MailPoetTest {
|
|||||||
'api_version' => 'v1',
|
'api_version' => 'v1',
|
||||||
'data' => ['test' => 'data'],
|
'data' => ['test' => 'data'],
|
||||||
];
|
];
|
||||||
$this->api->setRequestData($data);
|
$this->api->setRequestData($data, Endpoint::TYPE_POST);
|
||||||
$response = $this->api->processRoute();
|
$response = $this->api->processRoute();
|
||||||
|
|
||||||
expect($response->getData()['data'])->equals($data['data']);
|
expect($response->getData()['data'])->equals($data['data']);
|
||||||
@@ -151,7 +152,7 @@ class APITest extends \MailPoetTest {
|
|||||||
'api_version' => 'v2',
|
'api_version' => 'v2',
|
||||||
'method' => 'testVersion',
|
'method' => 'testVersion',
|
||||||
];
|
];
|
||||||
$this->api->setRequestData($data);
|
$this->api->setRequestData($data, Endpoint::TYPE_POST);
|
||||||
$response = $this->api->processRoute();
|
$response = $this->api->processRoute();
|
||||||
expect($response->getData()['data'])->equals($data['api_version']);
|
expect($response->getData()['data'])->equals($data['api_version']);
|
||||||
}
|
}
|
||||||
@@ -187,7 +188,7 @@ class APITest extends \MailPoetTest {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
$api->addEndpointNamespace($namespace['name'], $namespace['version']);
|
$api->addEndpointNamespace($namespace['name'], $namespace['version']);
|
||||||
$api->setRequestData($data);
|
$api->setRequestData($data, Endpoint::TYPE_POST);
|
||||||
$response = $api->processRoute();
|
$response = $api->processRoute();
|
||||||
expect($response->getData()['data'])->equals($data['data']);
|
expect($response->getData()['data'])->equals($data['data']);
|
||||||
}
|
}
|
||||||
@@ -210,7 +211,7 @@ class APITest extends \MailPoetTest {
|
|||||||
|
|
||||||
$api = new JSONAPI($this->container, $access_control, $this->settings, new WPFunctions);
|
$api = new JSONAPI($this->container, $access_control, $this->settings, new WPFunctions);
|
||||||
$api->addEndpointNamespace($namespace['name'], $namespace['version']);
|
$api->addEndpointNamespace($namespace['name'], $namespace['version']);
|
||||||
$api->setRequestData($data);
|
$api->setRequestData($data, Endpoint::TYPE_POST);
|
||||||
$response = $api->processRoute();
|
$response = $api->processRoute();
|
||||||
expect($response->status)->equals(Response::STATUS_FORBIDDEN);
|
expect($response->status)->equals(Response::STATUS_FORBIDDEN);
|
||||||
}
|
}
|
||||||
@@ -293,7 +294,7 @@ class APITest extends \MailPoetTest {
|
|||||||
'api_version' => 'v2',
|
'api_version' => 'v2',
|
||||||
'method' => 'fakeMethod',
|
'method' => 'fakeMethod',
|
||||||
];
|
];
|
||||||
$this->api->setRequestData($data);
|
$this->api->setRequestData($data, Endpoint::TYPE_POST);
|
||||||
$response = $this->api->processRoute();
|
$response = $this->api->processRoute();
|
||||||
|
|
||||||
expect($response->status)->equals(Response::STATUS_BAD_REQUEST);
|
expect($response->status)->equals(Response::STATUS_BAD_REQUEST);
|
||||||
|
Reference in New Issue
Block a user