Use short array syntax

[MAILPOET-2090]
This commit is contained in:
Pavel Dohnal
2019-05-20 13:48:48 +02:00
committed by M. Shull
parent 9f16cb6a5f
commit 5da7110eb6
385 changed files with 40133 additions and 40131 deletions

View File

@@ -12,53 +12,53 @@ use MailPoet\Subscribers\ImportExport\Export\DynamicSubscribersGetter;
class DynamicSubscribersGetterTest extends \MailPoetTest {
function _before() {
parent::_before();
$this->subscriber_fields = array(
$this->subscriber_fields = [
'first_name' => 'First name',
'last_name' => 'Last name',
'email' => 'Email',
1 => 'Country'
);
1 => 'Country',
];
$this->subscribers_data = array(
array(
$this->subscribers_data = [
[
'first_name' => 'Adam',
'last_name' => 'Smith',
'email' => 'adam@smith.com',
),
array(
],
[
'first_name' => 'Mary',
'last_name' => 'Jane',
'email' => 'mary@jane.com',
'status' => Subscriber::STATUS_SUBSCRIBED,
1 => 'Brazil'
),
array(
1 => 'Brazil',
],
[
'first_name' => 'John',
'last_name' => 'Kookoo',
'email' => 'john@kookoo.com'
),
array(
'email' => 'john@kookoo.com',
],
[
'first_name' => 'Paul',
'last_name' => 'Newman',
'email' => 'paul@newman.com'
)
);
'email' => 'paul@newman.com',
],
];
$this->custom_fields_data = array(
array(
$this->custom_fields_data = [
[
'name' => 'Country',
'type' => 'text'
)
);
'type' => 'text',
],
];
$this->segments_data = array(
array(
'name' => 'Newspapers'
),
array(
'name' => 'Journals'
)
);
$this->segments_data = [
[
'name' => 'Newspapers',
],
[
'name' => 'Journals',
],
];
foreach ($this->subscribers_data as $subscriber) {
if (isset($subscriber[1])) {
@@ -92,23 +92,23 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'mailpoet_get_segment_filters',
function($segment_id) {
if ($segment_id == 1) {
return array(new \DynamicSegmentFilter([1, 2]));
return [new \DynamicSegmentFilter([1, 2])];
} else if ($segment_id == 2) {
return array(new \DynamicSegmentFilter([1, 3, 4]));
return [new \DynamicSegmentFilter([1, 3, 4])];
}
return array();
return [];
}
);
}
protected function filterSubscribersData($subscribers) {
return array_map(function($subscriber) {
$data = array();
$data = [];
foreach ($subscriber as $key => $value) {
if (in_array($key, array(
if (in_array($key, [
'first_name', 'last_name', 'email', 'global_status',
'status', 'list_status', 'segment_name', 1
)))
'status', 'list_status', 'segment_name', 1,
]))
$data[$key] = $value;
}
return $data;
@@ -119,7 +119,7 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
$getter = new DynamicSubscribersGetter([1], 10);
$subscribers = $getter->get();
expect($this->filterSubscribersData($subscribers))->equals([
array(
[
'first_name' => 'Adam',
'last_name' => 'Smith',
'email' => 'adam@smith.com',
@@ -127,9 +127,9 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'global_status' => Subscriber::STATUS_UNCONFIRMED,
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Newspapers',
1 => null
),
array(
1 => null,
],
[
'first_name' => 'Mary',
'last_name' => 'Jane',
'email' => 'mary@jane.com',
@@ -138,7 +138,7 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'list_status' => Subscriber::STATUS_SUBSCRIBED,
'segment_name' => 'Newspapers',
1 => 'Brazil',
),
],
]);
expect($getter->get())->equals(false);
@@ -147,7 +147,7 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
function testItGetsSubscribersInMultipleSegments() {
$getter = new DynamicSubscribersGetter([1, 2], 10);
expect($this->filterSubscribersData($getter->get()))->equals([
array(
[
'first_name' => 'Adam',
'last_name' => 'Smith',
'email' => 'adam@smith.com',
@@ -155,9 +155,9 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'global_status' => Subscriber::STATUS_UNCONFIRMED,
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Newspapers',
1 => null
),
array(
1 => null,
],
[
'first_name' => 'Mary',
'last_name' => 'Jane',
'email' => 'mary@jane.com',
@@ -166,11 +166,11 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'list_status' => Subscriber::STATUS_SUBSCRIBED,
'segment_name' => 'Newspapers',
1 => 'Brazil',
),
],
]);
expect($this->filterSubscribersData($getter->get()))->equals([
array(
[
'first_name' => 'Adam',
'last_name' => 'Smith',
'email' => 'adam@smith.com',
@@ -178,9 +178,9 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'global_status' => Subscriber::STATUS_UNCONFIRMED,
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Journals',
1 => null
),
array(
1 => null,
],
[
'first_name' => 'John',
'last_name' => 'Kookoo',
'email' => 'john@kookoo.com',
@@ -189,8 +189,8 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Journals',
1 => null,
),
array(
],
[
'first_name' => 'Paul',
'last_name' => 'Newman',
'email' => 'paul@newman.com',
@@ -199,7 +199,7 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Journals',
1 => null,
),
],
]);
expect($getter->get())->equals(false);
@@ -208,7 +208,7 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
function testItGetsSubscribersInBatches() {
$getter = new DynamicSubscribersGetter([1, 2], 2);
expect($this->filterSubscribersData($getter->get()))->equals([
array(
[
'first_name' => 'Adam',
'last_name' => 'Smith',
'email' => 'adam@smith.com',
@@ -216,9 +216,9 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'global_status' => Subscriber::STATUS_UNCONFIRMED,
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Newspapers',
1 => null
),
array(
1 => null,
],
[
'first_name' => 'Mary',
'last_name' => 'Jane',
'email' => 'mary@jane.com',
@@ -227,13 +227,13 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'list_status' => Subscriber::STATUS_SUBSCRIBED,
'segment_name' => 'Newspapers',
1 => 'Brazil',
),
],
]);
expect($this->filterSubscribersData($getter->get()))->equals([]);
expect($this->filterSubscribersData($getter->get()))->equals([
array(
[
'first_name' => 'Adam',
'last_name' => 'Smith',
'email' => 'adam@smith.com',
@@ -241,9 +241,9 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'global_status' => Subscriber::STATUS_UNCONFIRMED,
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Journals',
1 => null
),
array(
1 => null,
],
[
'first_name' => 'John',
'last_name' => 'Kookoo',
'email' => 'john@kookoo.com',
@@ -252,11 +252,11 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Journals',
1 => null,
),
],
]);
expect($this->filterSubscribersData($getter->get()))->equals([
array(
[
'first_name' => 'Paul',
'last_name' => 'Newman',
'email' => 'paul@newman.com',
@@ -265,7 +265,7 @@ class DynamicSubscribersGetterTest extends \MailPoetTest {
'list_status' => Subscriber::STATUS_UNCONFIRMED,
'segment_name' => 'Journals',
1 => null,
),
],
]);
expect($getter->get())->equals(false);