2018-02-15 19:19:53 +03:00
|
|
|
<?php
|
2018-09-02 13:44:21 +03:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-02-15 19:19:53 +03:00
|
|
|
namespace GraphQL\Tests\Utils;
|
|
|
|
|
|
|
|
use GraphQL\Utils\Utils;
|
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
|
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Does not accept an empty list')
|
2018-02-15 19:19:53 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testResturnsResultsWhenInputIsEmpty() : void
|
2018-02-15 19:19:53 +03:00
|
|
|
{
|
2018-07-29 18:43:10 +03:00
|
|
|
$this->expectException(\LogicException::class);
|
2018-02-15 19:19:53 +03:00
|
|
|
Utils::quotedOrList([]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Returns single quoted item')
|
2018-02-15 19:19:53 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testReturnsSingleQuotedItem() : void
|
2018-02-15 19:19:53 +03:00
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'"A"',
|
|
|
|
Utils::quotedOrList(['A'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Returns two item list')
|
2018-02-15 19:19:53 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testReturnsTwoItemList() : void
|
2018-02-15 19:19:53 +03:00
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'"A" or "B"',
|
|
|
|
Utils::quotedOrList(['A', 'B'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Returns comma separated many item list')
|
2018-02-15 19:19:53 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testReturnsCommaSeparatedManyItemList() : void
|
2018-02-15 19:19:53 +03:00
|
|
|
{
|
|
|
|
$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'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Limits to five items')
|
2018-02-15 19:19:53 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testLimitsToFiveItems() : void
|
2018-02-15 19:19:53 +03:00
|
|
|
{
|
|
|
|
$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'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|