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),
function ($list, $index) use ($selected, $selectedLength) {
return $list.
($selectedLength > 2 && $index !== $selectedLength - 1? ', ' : ' ') .
($selectedLength > 2 ? ', ' : ' ') .
($index === $selectedLength - 1 ? 'or ' : '') .
$selected[$index];
},

View File

@ -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'])
);
}

View File

@ -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',