2018-02-15 17:19:53 +01:00
|
|
|
<?php
|
|
|
|
namespace GraphQL\Tests\Utils;
|
|
|
|
|
|
|
|
use GraphQL\Executor\Values;
|
|
|
|
use GraphQL\Type\Definition\Type;
|
|
|
|
use GraphQL\Utils\Utils;
|
|
|
|
use GraphQL\Utils\Value;
|
2018-07-29 17:43:10 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-02-15 17:19:53 +01:00
|
|
|
|
2018-07-29 17:43:10 +02:00
|
|
|
class QuotedOrListTest extends TestCase
|
2018-02-15 17:19:53 +01:00
|
|
|
{
|
|
|
|
// DESCRIBE: quotedOrList
|
|
|
|
|
|
|
|
/**
|
2018-08-31 10:55:14 +02:00
|
|
|
* @see it('Does not accept an empty list')
|
2018-02-15 17:19:53 +01:00
|
|
|
*/
|
|
|
|
public function testResturnsResultsWhenInputIsEmpty()
|
|
|
|
{
|
2018-07-29 17:43:10 +02:00
|
|
|
$this->expectException(\LogicException::class);
|
2018-02-15 17:19:53 +01:00
|
|
|
Utils::quotedOrList([]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 10:55:14 +02:00
|
|
|
* @see it('Returns single quoted item')
|
2018-02-15 17:19:53 +01:00
|
|
|
*/
|
|
|
|
public function testReturnsSingleQuotedItem()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'"A"',
|
|
|
|
Utils::quotedOrList(['A'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 10:55:14 +02:00
|
|
|
* @see it('Returns two item list')
|
2018-02-15 17:19:53 +01:00
|
|
|
*/
|
|
|
|
public function testReturnsTwoItemList()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'"A" or "B"',
|
|
|
|
Utils::quotedOrList(['A', 'B'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 10:55:14 +02:00
|
|
|
* @see it('Returns comma separated many item list')
|
2018-02-15 17:19:53 +01:00
|
|
|
*/
|
|
|
|
public function testReturnsCommaSeparatedManyItemList()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
2018-02-16 16:39:59 +01:00
|
|
|
'"A", "B", or "C"',
|
2018-02-15 17:19:53 +01:00
|
|
|
Utils::quotedOrList(['A', 'B', 'C'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 10:55:14 +02:00
|
|
|
* @see it('Limits to five items')
|
2018-02-15 17:19:53 +01:00
|
|
|
*/
|
|
|
|
public function testLimitsToFiveItems()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
2018-02-16 16:39:59 +01:00
|
|
|
'"A", "B", "C", "D", or "E"',
|
2018-02-15 17:19:53 +01:00
|
|
|
Utils::quotedOrList(['A', 'B', 'C', 'D', 'E', 'F'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|