From dc6e814de339792e79a97dda7d074724d02445e5 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Fri, 16 Feb 2018 16:39:59 +0100 Subject: [PATCH] Fix orList to be the same as in JS and follow the chicago style for commas --- src/Utils/Utils.php | 2 +- tests/Utils/QuotedOrListTest.php | 4 ++-- tests/Validator/FieldsOnCorrectTypeTest.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Utils/Utils.php b/src/Utils/Utils.php index c9c3452..ee202ae 100644 --- a/src/Utils/Utils.php +++ b/src/Utils/Utils.php @@ -500,7 +500,7 @@ class Utils range(1, $selectedLength - 1), function ($list, $index) use ($selected, $selectedLength) { return $list. - ($selectedLength > 2 && $index !== $selectedLength - 1? ', ' : ' ') . + ($selectedLength > 2 ? ', ' : ' ') . ($index === $selectedLength - 1 ? 'or ' : '') . $selected[$index]; }, diff --git a/tests/Utils/QuotedOrListTest.php b/tests/Utils/QuotedOrListTest.php index 861388b..d739c4c 100644 --- a/tests/Utils/QuotedOrListTest.php +++ b/tests/Utils/QuotedOrListTest.php @@ -47,7 +47,7 @@ class QuotedOrListTest extends \PHPUnit_Framework_TestCase public function testReturnsCommaSeparatedManyItemList() { $this->assertEquals( - '"A", "B" or "C"', + '"A", "B", or "C"', Utils::quotedOrList(['A', 'B', 'C']) ); } @@ -58,7 +58,7 @@ class QuotedOrListTest extends \PHPUnit_Framework_TestCase public function testLimitsToFiveItems() { $this->assertEquals( - '"A", "B", "C", "D" or "E"', + '"A", "B", "C", "D", or "E"', Utils::quotedOrList(['A', 'B', 'C', 'D', 'E', 'F']) ); } diff --git a/tests/Validator/FieldsOnCorrectTypeTest.php b/tests/Validator/FieldsOnCorrectTypeTest.php index f59bf6c..75a891e 100644 --- a/tests/Validator/FieldsOnCorrectTypeTest.php +++ b/tests/Validator/FieldsOnCorrectTypeTest.php @@ -322,7 +322,7 @@ class FieldsOnCorrectTypeTest extends TestCase public function testLimitsLotsOfTypeSuggestions() { $expected = 'Cannot query field "f" on type "T". ' . - 'Did you mean to use an inline fragment on "A", "B", "C", "D" or "E"?'; + 'Did you mean to use an inline fragment on "A", "B", "C", "D", or "E"?'; $this->assertEquals($expected, FieldsOnCorrectType::undefinedFieldMessage( 'f', @@ -338,7 +338,7 @@ class FieldsOnCorrectTypeTest extends TestCase public function testLimitsLotsOfFieldSuggestions() { $expected = 'Cannot query field "f" on type "T". ' . - 'Did you mean "z", "y", "x", "w" or "v"?'; + 'Did you mean "z", "y", "x", "w", or "v"?'; $this->assertEquals($expected, FieldsOnCorrectType::undefinedFieldMessage( 'f',