Fix orList to be the same as in JS and follow the chicago style for commas

This commit is contained in:
Daniel Tschinder 2018-02-16 16:39:59 +01:00
parent d92a2dab21
commit dc6e814de3
3 changed files with 5 additions and 5 deletions

View File

@ -500,7 +500,7 @@ class Utils
range(1, $selectedLength - 1), range(1, $selectedLength - 1),
function ($list, $index) use ($selected, $selectedLength) { function ($list, $index) use ($selected, $selectedLength) {
return $list. return $list.
($selectedLength > 2 && $index !== $selectedLength - 1? ', ' : ' ') . ($selectedLength > 2 ? ', ' : ' ') .
($index === $selectedLength - 1 ? 'or ' : '') . ($index === $selectedLength - 1 ? 'or ' : '') .
$selected[$index]; $selected[$index];
}, },

View File

@ -47,7 +47,7 @@ class QuotedOrListTest extends \PHPUnit_Framework_TestCase
public function testReturnsCommaSeparatedManyItemList() public function testReturnsCommaSeparatedManyItemList()
{ {
$this->assertEquals( $this->assertEquals(
'"A", "B" or "C"', '"A", "B", or "C"',
Utils::quotedOrList(['A', 'B', 'C']) Utils::quotedOrList(['A', 'B', 'C'])
); );
} }
@ -58,7 +58,7 @@ class QuotedOrListTest extends \PHPUnit_Framework_TestCase
public function testLimitsToFiveItems() public function testLimitsToFiveItems()
{ {
$this->assertEquals( $this->assertEquals(
'"A", "B", "C", "D" or "E"', '"A", "B", "C", "D", or "E"',
Utils::quotedOrList(['A', 'B', 'C', 'D', 'E', 'F']) Utils::quotedOrList(['A', 'B', 'C', 'D', 'E', 'F'])
); );
} }

View File

@ -322,7 +322,7 @@ class FieldsOnCorrectTypeTest extends TestCase
public function testLimitsLotsOfTypeSuggestions() public function testLimitsLotsOfTypeSuggestions()
{ {
$expected = 'Cannot query field "f" on type "T". ' . $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( $this->assertEquals($expected, FieldsOnCorrectType::undefinedFieldMessage(
'f', 'f',
@ -338,7 +338,7 @@ class FieldsOnCorrectTypeTest extends TestCase
public function testLimitsLotsOfFieldSuggestions() public function testLimitsLotsOfFieldSuggestions()
{ {
$expected = 'Cannot query field "f" on type "T". ' . $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( $this->assertEquals($expected, FieldsOnCorrectType::undefinedFieldMessage(
'f', 'f',