Validate only fields in form

[MAILPOET-1828]
This commit is contained in:
Pavel Dohnal
2019-04-03 13:12:47 +02:00
committed by M. Shull
parent 66663331c5
commit 6493f7ceb4
4 changed files with 66 additions and 9 deletions

View File

@ -468,14 +468,26 @@ class SubscribersTest extends \MailPoetTest {
}
function testItCannotSubscribeWithoutMandatoryCustomField() {
CustomField::createOrUpdate([
$custom_field = CustomField::createOrUpdate([
'name' => 'custom field',
'type' => 'text',
'params' => ['required' => '1']
]);
$form = Form::createOrUpdate([
'name' => 'form',
'body' => [[
'type' => 'text',
'name' => 'mandatory',
'id' => $custom_field->id(),
'unique' => '1',
'static' => '0',
'params' => ['required' => '1'],
'position' => '0',
]],
]);
$response = $this->endpoint->subscribe(array(
$this->obfuscatedEmail => 'toto@mailpoet.com',
'form_id' => $this->form->id,
'form_id' => $form->id,
$this->obfuscatedSegments => array($this->segment_1->id, $this->segment_2->id)
));
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);