Skip to content

Commit

Permalink
Merge pull request #19 from Stillat/analysis-APQ5EB
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
JohnathonKoster authored Feb 27, 2023
2 parents aff31c0 + 07743a1 commit ecaa34a
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 143 deletions.
2 changes: 1 addition & 1 deletion src/Analyzers/ConfigAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected function willClobberTheExistingArray(Array_ $node, ArrayItem $incoming
$willWreckArray = true;

foreach ($node->items as $item) {
if (! ($item instanceof ArrayItem && $item->value instanceof Array_)) {
if (!($item instanceof ArrayItem && $item->value instanceof Array_)) {
$willWreckArray = false;
break;
}
Expand Down
282 changes: 140 additions & 142 deletions tests/MergeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,70 +54,70 @@ public function testMergeDoesNotFlattenValues()
$updater->open(__DIR__.'/configs/issues/018.php');

$updater->update([
'forms' => [
[
'id' => 'new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
'forms' => [
[
'id' => 'new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
],
'merge_fields' => [
[
'id' => 'new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
'merge_fields' => [
[
'id' => 'new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
[
'id' => 'new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
[
'id' => 'new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
[
'id' => 'new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
[
'id' => 'new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
'primary_email_field' => 'email',
'audience_id' => 'new5',
],
[
'id' => 'b-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
'primary_email_field' => 'email',
'audience_id' => 'new5',
],
[
'id' => 'b-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
],
'merge_fields' => [
[
'id' => 'b-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
[
'id' => 'b-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
'merge_fields' => [
[
'id' => 'b-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
[
'id' => 'b-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
[
'id' => 'b-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
[
'id' => 'b-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
'primary_email_field' => 'email',
'audience_id' => 'b-new5',
],
'primary_email_field' => 'email',
'audience_id' => 'b-new5',
],
],

],true);
], true);

$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018.php'));
$this->assertSame($expected, $updater->getDocument());
Expand All @@ -126,146 +126,144 @@ public function testMergeDoesNotFlattenValues()
$updater->open(__DIR__.'/expected/issues/018.php');

$updater->update([
'forms' => [
[
'id' => 'c-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
'forms' => [
[
'id' => 'c-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
],
'merge_fields' => [
[
'id' => 'c-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
[
'id' => 'c-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
'merge_fields' => [
[
'id' => 'c-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
[
'id' => 'c-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
[
'id' => 'c-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
[
'id' => 'c-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
'primary_email_field' => 'email',
'audience_id' => 'c-new5',
],
[
'id' => 'd-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
'primary_email_field' => 'email',
'audience_id' => 'c-new5',
],
[
'id' => 'd-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
],
'merge_fields' => [
[
'id' => 'd-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
[
'id' => 'd-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
'merge_fields' => [
[
'id' => 'd-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
],
[
'id' => 'd-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
],
[
'id' => 'd-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
[
'id' => 'd-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
],
'primary_email_field' => 'email',
'audience_id' => 'd-new5',
],
'primary_email_field' => 'email',
'audience_id' => 'd-new5',
],
],

],true);

$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018a.php'));
$this->assertSame($expected, $updater->getDocument());
], true);

$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018a.php'));
$this->assertSame($expected, $updater->getDocument());

$updater = new ConfigUpdater();
$updater->open(__DIR__.'/expected/issues/018a.php');

$updater->update([
'forms' => [
[
'id' => 'c-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'id' => 'c-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
],
'merge_fields' => [
[
'id' => 'c-new2',
'id' => 'c-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
'tag' => 'FNAME',
],
[
'id' => 'c-new3',
'id' => 'c-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
'tag' => 'LNAME',
],
[
'id' => 'c-new4',
'id' => 'c-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
'tag' => 'COMPANY',
],
],
'primary_email_field' => 'email',
'audience_id' => 'c-new5',
'audience_id' => 'c-new5',
],
[
'id' => 'd-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'id' => 'd-new1',
'form' => 'contact',
'check_consent' => true,
'consent_field' => 'newsletter',
'disable_opt_in' => false,
'marketing_permissions_field_ids' => [
[
],
],
'merge_fields' => [
[
'id' => 'd-new2',
'id' => 'd-new2',
'field_name' => 'first_name',
'tag' => 'FNAME',
'tag' => 'FNAME',
],
[
'id' => 'd-new3',
'id' => 'd-new3',
'field_name' => 'last_name',
'tag' => 'LNAME',
'tag' => 'LNAME',
],
[
'id' => 'd-new4',
'id' => 'd-new4',
'field_name' => 'company',
'tag' => 'COMPANY',
'tag' => 'COMPANY',
],
],
'primary_email_field' => 'email',
'audience_id' => 'd-new5',
'audience_id' => 'd-new5',
],
],

],false);

], false);

$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018b.php'));
$this->assertSame($expected, $updater->getDocument());
}
}
}

0 comments on commit ecaa34a

Please sign in to comment.