Use short array syntax
[MAILPOET-2090]
This commit is contained in:
@ -6,50 +6,50 @@ use MailPoet\API\JSON\Response as APIResponse;
|
||||
use MailPoet\Models\CustomField;
|
||||
|
||||
class CustomFieldsTest extends \MailPoetTest {
|
||||
private $custom_fields = array(
|
||||
array(
|
||||
private $custom_fields = [
|
||||
[
|
||||
'name' => 'CF: text',
|
||||
'type' => 'text',
|
||||
'params' => array(
|
||||
'params' => [
|
||||
'required' => '1',
|
||||
'validate' => '',
|
||||
'label' => 'CF: text'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'label' => 'CF: text',
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'CF: textarea',
|
||||
'type' => 'textarea',
|
||||
'params' => array(
|
||||
'params' => [
|
||||
'required' => '1',
|
||||
'validate' => '',
|
||||
'label' => 'CF: text area'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'label' => 'CF: text area',
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'CF: radio',
|
||||
'type' => 'radio',
|
||||
'params' => array(
|
||||
'params' => [
|
||||
'values' =>
|
||||
array(
|
||||
array('value' => 'one'),
|
||||
array('value' => 'two'),
|
||||
array('value' => 'three')
|
||||
),
|
||||
[
|
||||
['value' => 'one'],
|
||||
['value' => 'two'],
|
||||
['value' => 'three'],
|
||||
],
|
||||
'required' => '1',
|
||||
'label' => 'CF: radio'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'label' => 'CF: radio',
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'CF: date',
|
||||
'type' => 'date',
|
||||
'params' => array(
|
||||
'params' => [
|
||||
'required' => '1',
|
||||
'date_type' => 'year_month_day',
|
||||
'date_format' => '',
|
||||
'label' => 'CF: date'
|
||||
)
|
||||
)
|
||||
);
|
||||
'label' => 'CF: date',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
function _before() {
|
||||
parent::_before();
|
||||
@ -76,33 +76,33 @@ class CustomFieldsTest extends \MailPoetTest {
|
||||
$custom_field_id = $custom_field->id();
|
||||
|
||||
$router = new CustomFields();
|
||||
$response = $router->delete(array('id' => $custom_field_id));
|
||||
$response = $router->delete(['id' => $custom_field_id]);
|
||||
expect($response->status)->equals(APIResponse::STATUS_OK);
|
||||
|
||||
$custom_field = CustomField::where('type', 'date')->findOne();
|
||||
expect($custom_field)->false();
|
||||
|
||||
$response = $router->delete(array('id' => $custom_field_id));
|
||||
$response = $router->delete(['id' => $custom_field_id]);
|
||||
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
function testItCanSaveACustomField() {
|
||||
$new_custom_field = array(
|
||||
$new_custom_field = [
|
||||
'name' => 'New custom field',
|
||||
'type' => 'text'
|
||||
);
|
||||
'type' => 'text',
|
||||
];
|
||||
|
||||
$router = new CustomFields();
|
||||
$response = $router->save($new_custom_field);
|
||||
expect($response->status)->equals(APIResponse::STATUS_OK);
|
||||
|
||||
// missing type
|
||||
$response = $router->save(array('name' => 'New custom field'));
|
||||
$response = $router->save(['name' => 'New custom field']);
|
||||
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
||||
expect($response->errors[0]['message'])->equals('Please specify a type.');
|
||||
|
||||
// missing name
|
||||
$response = $router->save(array('type' => 'text'));
|
||||
$response = $router->save(['type' => 'text']);
|
||||
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
||||
expect($response->errors[0]['message'])->equals('Please specify a name.');
|
||||
|
||||
@ -117,13 +117,13 @@ class CustomFieldsTest extends \MailPoetTest {
|
||||
$custom_field = CustomField::where('name', 'CF: text')->findOne();
|
||||
|
||||
$router = new CustomFields();
|
||||
$response = $router->get(array('id' => $custom_field->id()));
|
||||
$response = $router->get(['id' => $custom_field->id()]);
|
||||
|
||||
expect($response->data['name'])->equals('CF: text');
|
||||
expect($response->data['type'])->equals('text');
|
||||
expect($response->data['params'])->notEmpty();
|
||||
|
||||
$response = $router->get(array('id' => 'not_an_id'));
|
||||
$response = $router->get(['id' => 'not_an_id']);
|
||||
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user