aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-01-25 09:16:13 +0100
committerGravatar GitHub <noreply@github.com> 2025-01-25 09:16:13 +0100
commitd6c2daee51fa90f000c106492141baf3824931d2 (patch)
tree98357a95438a55c9399cc1e1520c96996536b9c6 /tests
parent22b74b0a5790360d81088a83addab1f98b7f7947 (diff)
Add search operator intext: (#7228)
* Add search operator intext: fix https://github.com/FreshRSS/FreshRSS/issues/6188 https://github.com/FreshRSS/FreshRSS/discussions/7220 * Add example to doc
Diffstat (limited to 'tests')
-rw-r--r--tests/app/Models/SearchTest.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php
index 81b4ac1fb..a62e255de 100644
--- a/tests/app/Models/SearchTest.php
+++ b/tests/app/Models/SearchTest.php
@@ -71,6 +71,27 @@ class SearchTest extends PHPUnit\Framework\TestCase {
}
/**
+ * @param array<string>|null $intext_value
+ * @param array<string>|null $search_value
+ */
+ #[DataProvider('provideIntextSearch')]
+ public static function test__construct_whenInputContainsIntext(string $input, ?array $intext_value, ?array $search_value): void {
+ $search = new FreshRSS_Search($input);
+ self::assertSame($intext_value, $search->getIntext());
+ self::assertSame($search_value, $search->getSearch());
+ }
+
+ /**
+ * @return list<list<mixed>>
+ */
+ public static function provideIntextSearch(): array {
+ return [
+ ['intext:word1', ['word1'], null],
+ ['intext:"word1 word2"', ['word1 word2'], null],
+ ];
+ }
+
+ /**
* @param array<string>|null $author_value
* @param array<string>|null $search_value
*/
@@ -380,6 +401,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {
['%"hello world"%'],
],
[
+ 'intext:\'"hello world"\'',
+ '(e.content LIKE ? )',
+ ['%"hello world"%'],
+ ],
+ [
'(ab) OR (cd) OR (ef)',
'(((e.title LIKE ? OR e.content LIKE ?) )) OR (((e.title LIKE ? OR e.content LIKE ?) )) OR (((e.title LIKE ? OR e.content LIKE ?) ))',
['%ab%', '%ab%', '%cd%', '%cd%', '%ef%', '%ef%'],
@@ -469,6 +495,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {
'(e.title ~ ? )',
['^(ab|cd)']
],
+ [
+ 'intext:/^(ab|cd)/',
+ '(e.content ~ ? )',
+ ['^(ab|cd)']
+ ],
];
}
@@ -506,6 +537,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {
['^ab\\M']
],
[
+ 'intext:/^ab\\M/',
+ '(e.content ~ ? )',
+ ['^ab\\M']
+ ],
+ [
'author:/^ab$/',
"(REPLACE(e.author, ';', '\n') ~ ? )",
['^ab$']
@@ -573,6 +609,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {
"(e.title REGEXP ? )",
['(?-i)(?m)^ab$']
],
+ [
+ 'intext:/^ab$/m',
+ '(UNCOMPRESS(e.content_bin) REGEXP ?) )',
+ ['(?-i)(?m)^ab$']
+ ],
];
}
@@ -606,6 +647,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {
"(REGEXP_LIKE(e.title,?,'mc') )",
['^ab$']
],
+ [
+ 'intext:/^ab$/m',
+ "(REGEXP_LIKE(UNCOMPRESS(e.content_bin),?,'mc')) )",
+ ['^ab$']
+ ],
];
}
@@ -642,6 +688,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {
'(e.title REGEXP ? )',
['/^ab\\b/']
],
+ [
+ 'intext:/^ab\\b/',
+ '(e.content REGEXP ? )',
+ ['/^ab\\b/']
+ ],
];
}
}