2018-02-15 19:19:53 +03: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 18:43:10 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-02-15 19:19:53 +03:00
|
|
|
|
2018-07-29 18:43:10 +03:00
|
|
|
class QuotedOrListTest extends TestCase
|
2018-02-15 19:19:53 +03:00
|
|
|
{
|
|
|
|
// DESCRIBE: quotedOrList
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Does not accept an empty list
|
|
|
|
*/
|
|
|
|
public function testResturnsResultsWhenInputIsEmpty()
|
|
|
|
{
|
2018-07-29 18:43:10 +03:00
|
|
|
$this->expectException(\LogicException::class);
|
2018-02-15 19:19:53 +03:00
|
|
|
Utils::quotedOrList([]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Returns single quoted item
|
|
|
|
*/
|
|
|
|
public function testReturnsSingleQuotedItem()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'"A"',
|
|
|
|
Utils::quotedOrList(['A'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Returns two item list
|
|
|
|
*/
|
|
|
|
public function testReturnsTwoItemList()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'"A" or "B"',
|
|
|
|
Utils::quotedOrList(['A', 'B'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Returns comma separated many item list
|
|
|
|
*/
|
|
|
|
public function testReturnsCommaSeparatedManyItemList()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
2018-02-16 18:39:59 +03:00
|
|
|
'"A", "B", or "C"',
|
2018-02-15 19:19:53 +03:00
|
|
|
Utils::quotedOrList(['A', 'B', 'C'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @it Limits to five items
|
|
|
|
*/
|
|
|
|
public function testLimitsToFiveItems()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
2018-02-16 18:39:59 +03:00
|
|
|
'"A", "B", "C", "D", or "E"',
|
2018-02-15 19:19:53 +03:00
|
|
|
Utils::quotedOrList(['A', 'B', 'C', 'D', 'E', 'F'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|