graphql-php/tests/Utils/SuggestionListTest.php

46 lines
1006 B
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 SuggestionListTest extends TestCase
{
// DESCRIBE: suggestionList
/**
* @see it('Returns results when input is empty')
*/
public function testResturnsResultsWhenInputIsEmpty() : void
{
2018-09-19 18:12:09 +03:00
self::assertEquals(
Utils::suggestionList('', ['a']),
['a']
);
}
/**
* @see it('Returns empty array when there are no options')
*/
public function testReturnsEmptyArrayWhenThereAreNoOptions() : void
{
2018-09-19 18:12:09 +03:00
self::assertEquals(
Utils::suggestionList('input', []),
[]
);
}
/**
* @see it('Returns options sorted based on similarity')
*/
public function testReturnsOptionsSortedBasedOnSimilarity() : void
{
2018-09-19 18:12:09 +03:00
self::assertEquals(
Utils::suggestionList('abc', ['a', 'ab', 'abc']),
['abc', 'ab']
);
}
}