Add a new test for creating a custom field

[MAILPOET-3628]
This commit is contained in:
Pavel Dohnal
2021-09-22 10:50:11 +02:00
committed by Veljko V
parent 04c2061c12
commit 1aa93d1b3c
3 changed files with 28 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace MailPoet\Test\API\MP;
use MailPoet\API\MP\v1\API;
use MailPoet\API\MP\v1\APIException;
use MailPoet\CustomFields\CustomFieldsRepository;
use MailPoet\Entities\CustomFieldEntity;
@@ -80,4 +81,30 @@ class CustomFieldsTest extends \MailPoetTest {
],
]);
}
public function testItCreateNewCustomField() {
$response = $this->api->addSubscriberField([
'name' => 'text custom field',
'type' => 'text',
'params' => [
'required' => '1',
'label' => 'text custom field',
'date_type' => 'year_month_day',
],
]);
expect($response)->array();
expect($response)->hasKey('name');
}
public function testItFailsToCreateNewCustomField() {
$this->expectException(APIException::class);
$this->api->addSubscriberField([
'type' => 'text',
'params' => [
'required' => '1',
'label' => 'text custom field',
'date_type' => 'year_month_day',
],
]);
}
}