graphql-php/tests/Utils/QuotedOrListTest.php

66 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2018-09-02 13:44:21 +03:00
declare(strict_types=1);
namespace GraphQL\Tests\Utils;
use GraphQL\Utils\Utils;
2018-07-29 18:43:10 +03:00
use PHPUnit\Framework\TestCase;
2018-07-29 18:43:10 +03:00
class QuotedOrListTest extends TestCase
{
// DESCRIBE: quotedOrList
/**
* @see it('Does not accept an empty list')
*/
public function testResturnsResultsWhenInputIsEmpty() : void
{
2018-07-29 18:43:10 +03:00
$this->expectException(\LogicException::class);
Utils::quotedOrList([]);
}
/**
* @see it('Returns single quoted item')
*/
public function testReturnsSingleQuotedItem() : void
{
$this->assertEquals(
'"A"',
Utils::quotedOrList(['A'])
);
}
/**
* @see it('Returns two item list')
*/
public function testReturnsTwoItemList() : void
{
$this->assertEquals(
'"A" or "B"',
Utils::quotedOrList(['A', 'B'])
);
}
/**
* @see it('Returns comma separated many item list')
*/
public function testReturnsCommaSeparatedManyItemList() : void
{
$this->assertEquals(
'"A", "B", or "C"',
Utils::quotedOrList(['A', 'B', 'C'])
);
}
/**
* @see it('Limits to five items')
*/
public function testLimitsToFiveItems() : void
{
$this->assertEquals(
'"A", "B", "C", "D", or "E"',
Utils::quotedOrList(['A', 'B', 'C', 'D', 'E', 'F'])
);
}
}