|
@@ -6,9 +6,8 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider provideEmptyInput
|
|
* @dataProvider provideEmptyInput
|
|
|
- * @param string|null $input
|
|
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputIsEmpty_getsOnlyNullValues($input) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputIsEmpty_getsOnlyNullValues(?string $input): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals('', $search->getRawInput());
|
|
$this->assertEquals('', $search->getRawInput());
|
|
|
$this->assertNull($search->getIntitle());
|
|
$this->assertNull($search->getIntitle());
|
|
@@ -24,9 +23,9 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
/**
|
|
/**
|
|
|
* Return an array of values for the search object.
|
|
* Return an array of values for the search object.
|
|
|
* Here is the description of the values
|
|
* Here is the description of the values
|
|
|
- * @return array
|
|
|
|
|
|
|
+ * @return array{array{''},array{null}}
|
|
|
*/
|
|
*/
|
|
|
- public function provideEmptyInput() {
|
|
|
|
|
|
|
+ public function provideEmptyInput(): array {
|
|
|
return array(
|
|
return array(
|
|
|
array(''),
|
|
array(''),
|
|
|
array(null),
|
|
array(null),
|
|
@@ -35,20 +34,19 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider provideIntitleSearch
|
|
* @dataProvider provideIntitleSearch
|
|
|
- * @param string $input
|
|
|
|
|
- * @param string $intitle_value
|
|
|
|
|
- * @param string|null $search_value
|
|
|
|
|
|
|
+ * @param array<string>|null $intitle_value
|
|
|
|
|
+ * @param array<string>|null $search_value
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputContainsIntitle_setsIntitleProperty($input, $intitle_value, $search_value) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputContainsIntitle_setsIntitleProperty(string $input, ?array $intitle_value, ?array $search_value): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals($intitle_value, $search->getIntitle());
|
|
$this->assertEquals($intitle_value, $search->getIntitle());
|
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @return array
|
|
|
|
|
|
|
+ * @return array<array<mixed>>
|
|
|
*/
|
|
*/
|
|
|
- public function provideIntitleSearch() {
|
|
|
|
|
|
|
+ public function provideIntitleSearch(): array {
|
|
|
return array(
|
|
return array(
|
|
|
array('intitle:word1', array('word1'), null),
|
|
array('intitle:word1', array('word1'), null),
|
|
|
array('intitle:word1-word2', array('word1-word2'), null),
|
|
array('intitle:word1-word2', array('word1-word2'), null),
|
|
@@ -73,20 +71,19 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider provideAuthorSearch
|
|
* @dataProvider provideAuthorSearch
|
|
|
- * @param string $input
|
|
|
|
|
- * @param string $author_value
|
|
|
|
|
- * @param string|null $search_value
|
|
|
|
|
|
|
+ * @param array<string>|null $author_value
|
|
|
|
|
+ * @param array<string>|null $search_value
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputContainsAuthor_setsAuthorValue($input, $author_value, $search_value) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputContainsAuthor_setsAuthorValue(string $input, ?array $author_value, ?array $search_value): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals($author_value, $search->getAuthor());
|
|
$this->assertEquals($author_value, $search->getAuthor());
|
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @return array
|
|
|
|
|
|
|
+ * @return array<array<mixed>>
|
|
|
*/
|
|
*/
|
|
|
- public function provideAuthorSearch() {
|
|
|
|
|
|
|
+ public function provideAuthorSearch(): array {
|
|
|
return array(
|
|
return array(
|
|
|
array('author:word1', array('word1'), null),
|
|
array('author:word1', array('word1'), null),
|
|
|
array('author:word1-word2', array('word1-word2'), null),
|
|
array('author:word1-word2', array('word1-word2'), null),
|
|
@@ -111,20 +108,19 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider provideInurlSearch
|
|
* @dataProvider provideInurlSearch
|
|
|
- * @param string $input
|
|
|
|
|
- * @param string $inurl_value
|
|
|
|
|
- * @param string|null $search_value
|
|
|
|
|
|
|
+ * @param array<string>|null $inurl_value
|
|
|
|
|
+ * @param array<string>|null $search_value
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputContainsInurl_setsInurlValue($input, $inurl_value, $search_value) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputContainsInurl_setsInurlValue(string $input, ?array $inurl_value, ?array $search_value): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals($inurl_value, $search->getInurl());
|
|
$this->assertEquals($inurl_value, $search->getInurl());
|
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @return array
|
|
|
|
|
|
|
+ * @return array<array<mixed>>
|
|
|
*/
|
|
*/
|
|
|
- public function provideInurlSearch() {
|
|
|
|
|
|
|
+ public function provideInurlSearch(): array {
|
|
|
return array(
|
|
return array(
|
|
|
array('inurl:word1', array('word1'), null),
|
|
array('inurl:word1', array('word1'), null),
|
|
|
array('inurl: word1', array(), array('word1')),
|
|
array('inurl: word1', array(), array('word1')),
|
|
@@ -139,72 +135,65 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider provideDateSearch
|
|
* @dataProvider provideDateSearch
|
|
|
- * @param string $input
|
|
|
|
|
- * @param string $min_date_value
|
|
|
|
|
- * @param string $max_date_value
|
|
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputContainsDate_setsDateValues($input, $min_date_value, $max_date_value) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputContainsDate_setsDateValues(string $input, ?int $min_date_value, ?int $max_date_value): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals($min_date_value, $search->getMinDate());
|
|
$this->assertEquals($min_date_value, $search->getMinDate());
|
|
|
$this->assertEquals($max_date_value, $search->getMaxDate());
|
|
$this->assertEquals($max_date_value, $search->getMaxDate());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @return array
|
|
|
|
|
|
|
+ * @return array<array<mixed>>
|
|
|
*/
|
|
*/
|
|
|
- public function provideDateSearch() {
|
|
|
|
|
|
|
+ public function provideDateSearch(): array {
|
|
|
return array(
|
|
return array(
|
|
|
- array('date:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'),
|
|
|
|
|
- array('date:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210519799'),
|
|
|
|
|
- array('date:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172754001', '1210519800'),
|
|
|
|
|
|
|
+ array('date:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', 1172754000, 1210519800),
|
|
|
|
|
+ array('date:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', 1172754000, 1210519799),
|
|
|
|
|
+ array('date:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', 1172754001, 1210519800),
|
|
|
array('date:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1),
|
|
array('date:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1),
|
|
|
- array('date:2007-03-01/', strtotime('2007-03-01'), ''),
|
|
|
|
|
- array('date:/2008-05-11', '', strtotime('2008-05-12') - 1),
|
|
|
|
|
|
|
+ array('date:2007-03-01/', strtotime('2007-03-01'), null),
|
|
|
|
|
+ array('date:/2008-05-11', null, strtotime('2008-05-12') - 1),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider providePubdateSearch
|
|
* @dataProvider providePubdateSearch
|
|
|
- * @param string $input
|
|
|
|
|
- * @param string $min_pubdate_value
|
|
|
|
|
- * @param string $max_pubdate_value
|
|
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputContainsPubdate_setsPubdateValues($input, $min_pubdate_value, $max_pubdate_value) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputContainsPubdate_setsPubdateValues(string $input, ?int $min_pubdate_value, ?int $max_pubdate_value): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals($min_pubdate_value, $search->getMinPubdate());
|
|
$this->assertEquals($min_pubdate_value, $search->getMinPubdate());
|
|
|
$this->assertEquals($max_pubdate_value, $search->getMaxPubdate());
|
|
$this->assertEquals($max_pubdate_value, $search->getMaxPubdate());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @return array
|
|
|
|
|
|
|
+ * @return array<array<mixed>>
|
|
|
*/
|
|
*/
|
|
|
- public function providePubdateSearch() {
|
|
|
|
|
|
|
+ public function providePubdateSearch(): array {
|
|
|
return array(
|
|
return array(
|
|
|
- array('pubdate:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'),
|
|
|
|
|
- array('pubdate:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210519799'),
|
|
|
|
|
- array('pubdate:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172754001', '1210519800'),
|
|
|
|
|
|
|
+ array('pubdate:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', 1172754000, 1210519800),
|
|
|
|
|
+ array('pubdate:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', 1172754000, 1210519799),
|
|
|
|
|
+ array('pubdate:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', 1172754001, 1210519800),
|
|
|
array('pubdate:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1),
|
|
array('pubdate:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1),
|
|
|
- array('pubdate:2007-03-01/', strtotime('2007-03-01'), ''),
|
|
|
|
|
- array('pubdate:/2008-05-11', '', strtotime('2008-05-12') - 1),
|
|
|
|
|
|
|
+ array('pubdate:2007-03-01/', strtotime('2007-03-01'), null),
|
|
|
|
|
+ array('pubdate:/2008-05-11', null, strtotime('2008-05-12') - 1),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider provideTagsSearch
|
|
* @dataProvider provideTagsSearch
|
|
|
- * @param string $input
|
|
|
|
|
- * @param string $tags_value
|
|
|
|
|
- * @param string|null $search_value
|
|
|
|
|
|
|
+ * @param array<string>|null $tags_value
|
|
|
|
|
+ * @param array<string>|null $search_value
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputContainsTags_setsTagsValue($input, $tags_value, $search_value) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputContainsTags_setsTagsValue(string $input, ?array $tags_value, ?array $search_value): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals($tags_value, $search->getTags());
|
|
$this->assertEquals($tags_value, $search->getTags());
|
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
$this->assertEquals($search_value, $search->getSearch());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @return array
|
|
|
|
|
|
|
+ * @return array<array<string|array<string>|null>>
|
|
|
*/
|
|
*/
|
|
|
- public function provideTagsSearch() {
|
|
|
|
|
|
|
+ public function provideTagsSearch(): array {
|
|
|
return array(
|
|
return array(
|
|
|
array('#word1', array('word1'), null),
|
|
array('#word1', array('word1'), null),
|
|
|
array('# word1', array(), array('#', 'word1')),
|
|
array('# word1', array(), array('#', 'word1')),
|
|
@@ -219,19 +208,15 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @dataProvider provideMultipleSearch
|
|
* @dataProvider provideMultipleSearch
|
|
|
- * @param string $input
|
|
|
|
|
- * @param string $author_value
|
|
|
|
|
- * @param string $min_date_value
|
|
|
|
|
- * @param string $max_date_value
|
|
|
|
|
- * @param string $intitle_value
|
|
|
|
|
- * @param string $inurl_value
|
|
|
|
|
- * @param string $min_pubdate_value
|
|
|
|
|
- * @param string $max_pubdate_value
|
|
|
|
|
- * @param array $tags_value
|
|
|
|
|
- * @param string|null $search_value
|
|
|
|
|
|
|
+ * @param array<string>|null $author_value
|
|
|
|
|
+ * @param array<string> $intitle_value
|
|
|
|
|
+ * @param array<string>|null $inurl_value
|
|
|
|
|
+ * @param array<string>|null $tags_value
|
|
|
|
|
+ * @param array<string>|null $search_value
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_whenInputContainsMultipleKeywords_setsValues($input, $author_value, $min_date_value,
|
|
|
|
|
- $max_date_value, $intitle_value, $inurl_value, $min_pubdate_value, $max_pubdate_value, $tags_value, $search_value) {
|
|
|
|
|
|
|
+ public function test__construct_whenInputContainsMultipleKeywords_setsValues(string $input, ?array $author_value, ?int $min_date_value,
|
|
|
|
|
+ ?int $max_date_value, ?array $intitle_value, ?array $inurl_value, ?int $min_pubdate_value,
|
|
|
|
|
+ ?int $max_pubdate_value, ?array $tags_value, ?array $search_value): void {
|
|
|
$search = new FreshRSS_Search($input);
|
|
$search = new FreshRSS_Search($input);
|
|
|
$this->assertEquals($author_value, $search->getAuthor());
|
|
$this->assertEquals($author_value, $search->getAuthor());
|
|
|
$this->assertEquals($min_date_value, $search->getMinDate());
|
|
$this->assertEquals($min_date_value, $search->getMinDate());
|
|
@@ -245,7 +230,8 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
$this->assertEquals($input, $search->getRawInput());
|
|
$this->assertEquals($input, $search->getRawInput());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function provideMultipleSearch() {
|
|
|
|
|
|
|
+ /** @return array<array<mixed>> */
|
|
|
|
|
+ public function provideMultipleSearch(): array {
|
|
|
return array(
|
|
return array(
|
|
|
array(
|
|
array(
|
|
|
'author:word1 date:2007-03-01/2008-05-11 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 #word5',
|
|
'author:word1 date:2007-03-01/2008-05-11 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 #word5',
|
|
@@ -302,13 +288,14 @@ class SearchTest extends PHPUnit\Framework\TestCase {
|
|
|
* @dataProvider provideParentheses
|
|
* @dataProvider provideParentheses
|
|
|
* @param array<string> $values
|
|
* @param array<string> $values
|
|
|
*/
|
|
*/
|
|
|
- public function test__construct_parentheses(string $input, string $sql, $values) {
|
|
|
|
|
|
|
+ public function test__construct_parentheses(string $input, string $sql, array $values): void {
|
|
|
list($filterValues, $filterSearch) = FreshRSS_EntryDAOPGSQL::sqlBooleanSearch('e.', new FreshRSS_BooleanSearch($input));
|
|
list($filterValues, $filterSearch) = FreshRSS_EntryDAOPGSQL::sqlBooleanSearch('e.', new FreshRSS_BooleanSearch($input));
|
|
|
$this->assertEquals($sql, $filterSearch);
|
|
$this->assertEquals($sql, $filterSearch);
|
|
|
$this->assertEquals($values, $filterValues);
|
|
$this->assertEquals($values, $filterValues);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function provideParentheses() {
|
|
|
|
|
|
|
+ /** @return array<array<mixed>> */
|
|
|
|
|
+ public function provideParentheses(): array {
|
|
|
return [
|
|
return [
|
|
|
[
|
|
[
|
|
|
'f:1 (f:2 OR f:3 OR f:4) (f:5 OR (f:6 OR f:7))',
|
|
'f:1 (f:2 OR f:3 OR f:4) (f:5 OR (f:6 OR f:7))',
|