aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-04-03 18:42:52 +0200
committerGravatar GitHub <noreply@github.com> 2017-04-03 18:42:52 +0200
commit1cace07fd44efdce07249e04f9afcb5e7b5872dd (patch)
tree9bac4a6866a7c0b8780212525a26aad232c5c878
parentd6a51349e89c348e41de658421d74e130039a11f (diff)
parentccc95f6b93dae728b9d5be222c3af55d4ef10e1d (diff)
Merge pull request #1478 from Alkarex/better_search
Better search
-rw-r--r--CHANGELOG.md5
-rw-r--r--app/Models/EntryDAO.php69
-rw-r--r--app/Models/Search.php168
-rw-r--r--tests/README.md7
-rw-r--r--tests/app/Models/CategoryTest.php2
-rw-r--r--tests/app/Models/ContextTest.php5
-rw-r--r--tests/app/Models/SearchTest.php149
-rw-r--r--tests/app/Models/UserQueryTest.php2
8 files changed, 281 insertions, 126 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52e46a913..04cff5680 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,11 @@
## 2017-xx-xx FreshRSS 1.7.0-dev
* Features:
* Deferred insertion of new articles, for better chronological order [#530](https://github.com/FreshRSS/FreshRSS/issues/530)
+ * Better search:
+ * Possibility to use multiple `intitle:`, `inurl:`, `author:` [#1478](https://github.com/FreshRSS/FreshRSS/pull/1478)
+ * Negative searches with `!` or `-` [#1381](https://github.com/FreshRSS/FreshRSS/issues/1381)
+ * Examples: `!intitle:unwanted`, `-intitle:unwanted`, `-inurl:unwanted`, `-author:unwanted`, `-#unwanted`, `-unwanted`
+ * Allow double-quotes, such as `author:"some name"`, in addition to single-quotes such as `author:'some name'` [#1478](https://github.com/FreshRSS/FreshRSS/pull/1478)
* Compatibility:
* Add support for PHP 7.1 [#1471](https://github.com/FreshRSS/FreshRSS/issues/1471)
* PostgreSQL is not experimental anymore [#1476](https://github.com/FreshRSS/FreshRSS/pull/1476)
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 61ec48d08..7e836097a 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -630,18 +630,6 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
$search .= 'AND ' . $alias . 'id >= ' . $date_min . '000000 ';
}
if ($filter) {
- if ($filter->getIntitle()) {
- $search .= 'AND ' . $alias . 'title LIKE ? ';
- $values[] = "%{$filter->getIntitle()}%";
- }
- if ($filter->getInurl()) {
- $search .= 'AND CONCAT(' . $alias . 'link, ' . $alias . 'guid) LIKE ? ';
- $values[] = "%{$filter->getInurl()}%";
- }
- if ($filter->getAuthor()) {
- $search .= 'AND ' . $alias . 'author LIKE ? ';
- $values[] = "%{$filter->getAuthor()}%";
- }
if ($filter->getMinDate()) {
$search .= 'AND ' . $alias . 'id >= ? ';
$values[] = "{$filter->getMinDate()}000000";
@@ -658,20 +646,69 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
$search .= 'AND ' . $alias . 'date <= ? ';
$values[] = $filter->getMaxPubdate();
}
+
+ if ($filter->getAuthor()) {
+ foreach ($filter->getAuthor() as $author) {
+ $search .= 'AND ' . $alias . 'author LIKE ? ';
+ $values[] = "%{$author}%";
+ }
+ }
+ if ($filter->getIntitle()) {
+ foreach ($filter->getIntitle() as $title) {
+ $search .= 'AND ' . $alias . 'title LIKE ? ';
+ $values[] = "%{$title}%";
+ }
+ }
if ($filter->getTags()) {
- $tags = $filter->getTags();
- foreach ($tags as $tag) {
+ foreach ($filter->getTags() as $tag) {
$search .= 'AND ' . $alias . 'tags LIKE ? ';
$values[] = "%{$tag}%";
}
}
+ if ($filter->getInurl()) {
+ foreach ($filter->getInurl() as $url) {
+ $search .= 'AND CONCAT(' . $alias . 'link, ' . $alias . 'guid) LIKE ? ';
+ $values[] = "%{$url}%";
+ }
+ }
+
+ if ($filter->getNotAuthor()) {
+ foreach ($filter->getNotAuthor() as $author) {
+ $search .= 'AND (NOT ' . $alias . 'author LIKE ?) ';
+ $values[] = "%{$author}%";
+ }
+ }
+ if ($filter->getNotIntitle()) {
+ foreach ($filter->getNotIntitle() as $title) {
+ $search .= 'AND (NOT ' . $alias . 'title LIKE ?) ';
+ $values[] = "%{$title}%";
+ }
+ }
+ if ($filter->getNotTags()) {
+ foreach ($filter->getNotTags() as $tag) {
+ $search .= 'AND (NOT ' . $alias . 'tags LIKE ?) ';
+ $values[] = "%{$tag}%";
+ }
+ }
+ if ($filter->getNotInurl()) {
+ foreach ($filter->getNotInurl() as $url) {
+ $search .= 'AND (NOT CONCAT(' . $alias . 'link, ' . $alias . 'guid) LIKE ?) ';
+ $values[] = "%{$url}%";
+ }
+ }
+
if ($filter->getSearch()) {
- $search_values = $filter->getSearch();
- foreach ($search_values as $search_value) {
+ foreach ($filter->getSearch() as $search_value) {
$search .= 'AND ' . $this->sqlconcat($alias . 'title', $this->isCompressed() ? 'UNCOMPRESS(' . $alias . 'content_bin)' : '' . $alias . 'content') . ' LIKE ? ';
$values[] = "%{$search_value}%";
}
}
+ if ($filter->getNotSearch()) {
+ foreach ($filter->getNotSearch() as $search_value) {
+ $search .= 'AND (NOT ' . $this->sqlconcat($alias . 'title', $this->isCompressed() ? 'UNCOMPRESS(' . $alias . 'content_bin)' : '' . $alias . 'content') . ' LIKE ?) ';
+ $values[] = "%{$search_value}%";
+ }
+ }
}
return array($values, $search);
}
diff --git a/app/Models/Search.php b/app/Models/Search.php
index 575a9a2cb..5cc7f8e8d 100644
--- a/app/Models/Search.php
+++ b/app/Models/Search.php
@@ -23,18 +23,35 @@ class FreshRSS_Search {
private $tags;
private $search;
+ private $not_intitle;
+ private $not_inurl;
+ private $not_author;
+ private $not_tags;
+ private $not_search;
+
public function __construct($input) {
- if (strcmp($input, '') == 0) {
+ if ($input == '') {
return;
}
$this->raw_input = $input;
+
+ $input = preg_replace('/:&quot;(.*?)&quot;/', ':"\1"', $input);
+
+ $input = $this->parseNotIntitleSearch($input);
+ $input = $this->parseNotAuthorSearch($input);
+ $input = $this->parseNotInurlSearch($input);
+ $input = $this->parseNotTagsSeach($input);
+
+ $input = $this->parsePubdateSearch($input);
+ $input = $this->parseDateSearch($input);
+
$input = $this->parseIntitleSearch($input);
$input = $this->parseAuthorSearch($input);
$input = $this->parseInurlSearch($input);
- $input = $this->parsePubdateSearch($input);
- $input = $this->parseDateSearch($input);
$input = $this->parseTagsSeach($input);
- $this->parseSearch($input);
+
+ $input = $this->parseNotSearch($input);
+ $input = $this->parseSearch($input);
}
public function __toString() {
@@ -48,6 +65,9 @@ class FreshRSS_Search {
public function getIntitle() {
return $this->intitle;
}
+ public function getNotIntitle() {
+ return $this->not_intitle;
+ }
public function getMinDate() {
return $this->min_date;
@@ -68,18 +88,34 @@ class FreshRSS_Search {
public function getInurl() {
return $this->inurl;
}
+ public function getNotInurl() {
+ return $this->not_inurl;
+ }
public function getAuthor() {
return $this->author;
}
+ public function getNotAuthor() {
+ return $this->not_author;
+ }
public function getTags() {
return $this->tags;
}
+ public function getNotTags() {
+ return $this->not_tags;
+ }
public function getSearch() {
return $this->search;
}
+ public function getNotSearch() {
+ return $this->not_search;
+ }
+
+ private static function removeEmptyValues($anArray) {
+ return is_array($anArray) ? array_filter($anArray, function($value) { return $value !== ''; }) : array();
+ }
/**
* Parse the search string to find intitle keyword and the search related
@@ -90,14 +126,28 @@ class FreshRSS_Search {
* @return string
*/
private function parseIntitleSearch($input) {
- if (preg_match('/intitle:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
+ if (preg_match_all('/\bintitle:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
$this->intitle = $matches['search'];
- return str_replace($matches[0], '', $input);
+ $input = str_replace($matches[0], '', $input);
}
- if (preg_match('/intitle:(?P<search>\w*)/', $input, $matches)) {
- $this->intitle = $matches['search'];
- return str_replace($matches[0], '', $input);
+ if (preg_match_all('/\bintitle:(?P<search>\w*)/', $input, $matches)) {
+ $this->intitle = array_merge($this->intitle ? $this->intitle : array(), $matches['search']);
+ $input = str_replace($matches[0], '', $input);
+ }
+ $this->intitle = self::removeEmptyValues($this->intitle);
+ return $input;
+ }
+
+ private function parseNotIntitleSearch($input) {
+ if (preg_match_all('/[!-]intitle:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
+ $this->not_intitle = $matches['search'];
+ $input = str_replace($matches[0], '', $input);
+ }
+ if (preg_match_all('/[!-]intitle:(?P<search>\w*)/', $input, $matches)) {
+ $this->not_intitle = array_merge($this->not_intitle ? $this->not_intitle : array(), $matches['search']);
+ $input = str_replace($matches[0], '', $input);
}
+ $this->not_intitle = self::removeEmptyValues($this->not_intitle);
return $input;
}
@@ -112,30 +162,54 @@ class FreshRSS_Search {
* @return string
*/
private function parseAuthorSearch($input) {
- if (preg_match('/author:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
+ if (preg_match_all('/\bauthor:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
$this->author = $matches['search'];
- return str_replace($matches[0], '', $input);
+ $input = str_replace($matches[0], '', $input);
}
- if (preg_match('/author:(?P<search>\w*)/', $input, $matches)) {
- $this->author = $matches['search'];
- return str_replace($matches[0], '', $input);
+ if (preg_match_all('/\bauthor:(?P<search>\w*)/', $input, $matches)) {
+ $this->author = array_merge($this->author ? $this->author : array(), $matches['search']);
+ $input = str_replace($matches[0], '', $input);
}
+ $this->author = self::removeEmptyValues($this->author);
+ return $input;
+ }
+
+ private function parseNotAuthorSearch($input) {
+ if (preg_match_all('/[!-]author:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
+ $this->not_author = $matches['search'];
+ $input = str_replace($matches[0], '', $input);
+ }
+ if (preg_match_all('/[!-]author:(?P<search>\w*)/', $input, $matches)) {
+ $this->not_author = array_merge($this->not_author ? $this->not_author : array(), $matches['search']);
+ $input = str_replace($matches[0], '', $input);
+ }
+ $this->not_author = self::removeEmptyValues($this->not_author);
return $input;
}
/**
* Parse the search string to find inurl keyword and the search related
* to it.
- * The search is the first word following the keyword except.
+ * The search is the first word following the keyword.
*
* @param string $input
* @return string
*/
private function parseInurlSearch($input) {
- if (preg_match('/inurl:(?P<search>[^\s]*)/', $input, $matches)) {
+ if (preg_match_all('/\binurl:(?P<search>[^\s]*)/', $input, $matches)) {
$this->inurl = $matches['search'];
- return str_replace($matches[0], '', $input);
+ $input = str_replace($matches[0], '', $input);
+ }
+ $this->inurl = self::removeEmptyValues($this->inurl);
+ return $input;
+ }
+
+ private function parseNotInurlSearch($input) {
+ if (preg_match_all('/[!-]inurl:(?P<search>[^\s]*)/', $input, $matches)) {
+ $this->not_inurl = $matches['search'];
+ $input = str_replace($matches[0], '', $input);
}
+ $this->not_inurl = self::removeEmptyValues($this->not_inurl);
return $input;
}
@@ -148,9 +222,12 @@ class FreshRSS_Search {
* @return string
*/
private function parseDateSearch($input) {
- if (preg_match('/date:(?P<search>[^\s]*)/', $input, $matches)) {
- list($this->min_date, $this->max_date) = parseDateInterval($matches['search']);
- return str_replace($matches[0], '', $input);
+ if (preg_match_all('/\bdate:(?P<search>[^\s]*)/', $input, $matches)) {
+ $input = str_replace($matches[0], '', $input);
+ $dates = self::removeEmptyValues($matches['search']);
+ if (!empty($dates[0])) {
+ list($this->min_date, $this->max_date) = parseDateInterval($dates[0]);
+ }
}
return $input;
}
@@ -164,9 +241,12 @@ class FreshRSS_Search {
* @return string
*/
private function parsePubdateSearch($input) {
- if (preg_match('/pubdate:(?P<search>[^\s]*)/', $input, $matches)) {
- list($this->min_pubdate, $this->max_pubdate) = parseDateInterval($matches['search']);
- return str_replace($matches[0], '', $input);
+ if (preg_match_all('/\bpubdate:(?P<search>[^\s]*)/', $input, $matches)) {
+ $input = str_replace($matches[0], '', $input);
+ $dates = self::removeEmptyValues($matches['search']);
+ if (!empty($dates[0])) {
+ list($this->min_pubdate, $this->max_pubdate) = parseDateInterval($dates[0]);
+ }
}
return $input;
}
@@ -182,8 +262,18 @@ class FreshRSS_Search {
private function parseTagsSeach($input) {
if (preg_match_all('/#(?P<search>[^\s]+)/', $input, $matches)) {
$this->tags = $matches['search'];
- return str_replace($matches[0], '', $input);
+ $input = str_replace($matches[0], '', $input);
}
+ $this->tags = self::removeEmptyValues($this->tags);
+ return $input;
+ }
+
+ private function parseNotTagsSeach($input) {
+ if (preg_match_all('/[!-]#(?P<search>[^\s]+)/', $input, $matches)) {
+ $this->not_tags = $matches['search'];
+ $input = str_replace($matches[0], '', $input);
+ }
+ $this->not_tags = self::removeEmptyValues($this->not_tags);
return $input;
}
@@ -196,16 +286,16 @@ class FreshRSS_Search {
* @return string
*/
private function parseSearch($input) {
- $input = $this->cleanSearch($input);
- if (strcmp($input, '') == 0) {
+ $input = self::cleanSearch($input);
+ if ($input == '') {
return;
}
if (preg_match_all('/(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
$this->search = $matches['search'];
$input = str_replace($matches[0], '', $input);
}
- $input = $this->cleanSearch($input);
- if (strcmp($input, '') == 0) {
+ $input = self::cleanSearch($input);
+ if ($input == '') {
return;
}
if (is_array($this->search)) {
@@ -215,13 +305,33 @@ class FreshRSS_Search {
}
}
+ private function parseNotSearch($input) {
+ $input = self::cleanSearch($input);
+ if ($input == '') {
+ return;
+ }
+ if (preg_match_all('/[!-](?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
+ $this->not_search = $matches['search'];
+ $input = str_replace($matches[0], '', $input);
+ }
+ if ($input == '') {
+ return;
+ }
+ if (preg_match_all('/[!-](?P<search>[^\s]+)/', $input, $matches)) {
+ $this->not_search = array_merge(is_array($this->not_search) ? $this->not_search : array(), $matches['search']);
+ $input = str_replace($matches[0], '', $input);
+ }
+ $this->not_search = self::removeEmptyValues($this->not_search);
+ return $input;
+ }
+
/**
* Remove all unnecessary spaces in the search
*
* @param string $input
* @return string
*/
- private function cleanSearch($input) {
+ private static function cleanSearch($input) {
$input = preg_replace('/\s+/', ' ', $input);
return trim($input);
}
diff --git a/tests/README.md b/tests/README.md
new file mode 100644
index 000000000..3dd9602be
--- /dev/null
+++ b/tests/README.md
@@ -0,0 +1,7 @@
+# FreshRSS tests
+
+```sh
+cd ./tests/
+wget https://phar.phpunit.de/phpunit.phar
+php phpunit.phar --bootstrap bootstrap.php
+```
diff --git a/tests/app/Models/CategoryTest.php b/tests/app/Models/CategoryTest.php
index da439b785..2fd153aee 100644
--- a/tests/app/Models/CategoryTest.php
+++ b/tests/app/Models/CategoryTest.php
@@ -1,6 +1,6 @@
<?php
-class FreshRSS_CategoryTest extends \PHPUnit_Framework_TestCase {
+class FreshRSS_CategoryTest extends PHPUnit\Framework\TestCase {
public function test__construct_whenNoParameters_createsObjectWithDefaultValues() {
$category = new FreshRSS_Category();
diff --git a/tests/app/Models/ContextTest.php b/tests/app/Models/ContextTest.php
deleted file mode 100644
index 4dc8b7757..000000000
--- a/tests/app/Models/ContextTest.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-class ContextTest extends \PHPUnit_Framework_TestCase {
-
-}
diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php
index 73ff56cc6..4a7afc6f9 100644
--- a/tests/app/Models/SearchTest.php
+++ b/tests/app/Models/SearchTest.php
@@ -2,7 +2,7 @@
require_once(LIB_PATH . '/lib_date.php');
-class SearchTest extends \PHPUnit_Framework_TestCase {
+class SearchTest extends PHPUnit\Framework\TestCase {
/**
* @dataProvider provideEmptyInput
@@ -50,22 +50,22 @@ class SearchTest extends \PHPUnit_Framework_TestCase {
*/
public function provideIntitleSearch() {
return array(
- array('intitle:word1', 'word1', null),
- array('intitle:word1 word2', 'word1', array('word2')),
- array('intitle:"word1 word2"', 'word1 word2', null),
- array("intitle:'word1 word2'", 'word1 word2', null),
- array('word1 intitle:word2', 'word2', array('word1')),
- array('word1 intitle:word2 word3', 'word2', array('word1', 'word3')),
- array('word1 intitle:"word2 word3"', 'word2 word3', array('word1')),
- array("word1 intitle:'word2 word3'", 'word2 word3', array('word1')),
- array('intitle:word1 intitle:word2', 'word1', array('intitle:word2')),
- array('intitle: word1 word2', null, array('word1', 'word2')),
- array('intitle:123', '123', null),
- array('intitle:"word1 word2" word3"', 'word1 word2', array('word3"')),
- array("intitle:'word1 word2' word3'", 'word1 word2', array("word3'")),
- array('intitle:"word1 word2\' word3"', "word1 word2' word3", null),
- array("intitle:'word1 word2\" word3'", 'word1 word2" word3', null),
- array("intitle:word1 'word2 word3' word4", 'word1', array('word2 word3', 'word4')),
+ array('intitle:word1', array('word1'), null),
+ array('intitle:word1 word2', array('word1'), array('word2')),
+ array('intitle:"word1 word2"', array('word1 word2'), null),
+ array("intitle:'word1 word2'", array('word1 word2'), null),
+ array('word1 intitle:word2', array('word2'), array('word1')),
+ array('word1 intitle:word2 word3', array('word2'), array('word1', 'word3')),
+ array('word1 intitle:"word2 word3"', array('word2 word3'), array('word1')),
+ array("word1 intitle:'word2 word3'", array('word2 word3'), array('word1')),
+ array('intitle:word1 intitle:word2', array('word1', 'word2'), null),
+ array('intitle: word1 word2', array(), array('word1', 'word2')),
+ array('intitle:123', array('123'), null),
+ array('intitle:"word1 word2" word3"', array('word1 word2'), array('word3"')),
+ array("intitle:'word1 word2' word3'", array('word1 word2'), array("word3'")),
+ array('intitle:"word1 word2\' word3"', array("word1 word2' word3"), null),
+ array("intitle:'word1 word2\" word3'", array('word1 word2" word3'), null),
+ array("intitle:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')),
);
}
@@ -86,22 +86,22 @@ class SearchTest extends \PHPUnit_Framework_TestCase {
*/
public function provideAuthorSearch() {
return array(
- array('author:word1', 'word1', null),
- array('author:word1 word2', 'word1', array('word2')),
- array('author:"word1 word2"', 'word1 word2', null),
- array("author:'word1 word2'", 'word1 word2', null),
- array('word1 author:word2', 'word2', array('word1')),
- array('word1 author:word2 word3', 'word2', array('word1', 'word3')),
- array('word1 author:"word2 word3"', 'word2 word3', array('word1')),
- array("word1 author:'word2 word3'", 'word2 word3', array('word1')),
- array('author:word1 author:word2', 'word1', array('author:word2')),
- array('author: word1 word2', null, array('word1', 'word2')),
- array('author:123', '123', null),
- array('author:"word1 word2" word3"', 'word1 word2', array('word3"')),
- array("author:'word1 word2' word3'", 'word1 word2', array("word3'")),
- array('author:"word1 word2\' word3"', "word1 word2' word3", null),
- array("author:'word1 word2\" word3'", 'word1 word2" word3', null),
- array("author:word1 'word2 word3' word4", 'word1', array('word2 word3', 'word4')),
+ array('author:word1', array('word1'), null),
+ array('author:word1 word2', array('word1'), array('word2')),
+ array('author:"word1 word2"', array('word1 word2'), null),
+ array("author:'word1 word2'", array('word1 word2'), null),
+ array('word1 author:word2', array('word2'), array('word1')),
+ array('word1 author:word2 word3', array('word2'), array('word1', 'word3')),
+ array('word1 author:"word2 word3"', array('word2 word3'), array('word1')),
+ array("word1 author:'word2 word3'", array('word2 word3'), array('word1')),
+ array('author:word1 author:word2', array('word1', 'word2'), null),
+ array('author: word1 word2', array(), array('word1', 'word2')),
+ array('author:123', array('123'), null),
+ array('author:"word1 word2" word3"', array('word1 word2'), array('word3"')),
+ array("author:'word1 word2' word3'", array('word1 word2'), array("word3'")),
+ array('author:"word1 word2\' word3"', array("word1 word2' word3"), null),
+ array("author:'word1 word2\" word3'", array('word1 word2" word3'), null),
+ array("author:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')),
);
}
@@ -122,12 +122,13 @@ class SearchTest extends \PHPUnit_Framework_TestCase {
*/
public function provideInurlSearch() {
return array(
- array('inurl:word1', 'word1', null),
- array('inurl: word1', null, array('word1')),
- array('inurl:123', '123', null),
- array('inurl:word1 word2', 'word1', array('word2')),
- array('inurl:"word1 word2"', '"word1', array('word2"')),
- array("inurl:word1 'word2 word3' word4", 'word1', array('word2 word3', 'word4')),
+ array('inurl:word1', array('word1'), null),
+ array('inurl: word1', array(), array('word1')),
+ array('inurl:123', array('123'), null),
+ array('inurl:word1 word2', array('word1'), array('word2')),
+ array('inurl:"word1 word2"', array('"word1'), array('word2"')),
+ array('inurl:word1 word2 inurl:word3', array('word1', 'word3'), array('word2')),
+ array("inurl:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')),
);
}
@@ -151,9 +152,9 @@ class SearchTest extends \PHPUnit_Framework_TestCase {
array('date:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'),
array('date:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'),
array('date:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'),
- array('date:2007-03-01/2008-05-11', '1172725200', '1210564799'),
- array('date:2007-03-01/', '1172725200', ''),
- array('date:/2008-05-11', '', '1210564799'),
+ 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),
);
}
@@ -177,9 +178,9 @@ class SearchTest extends \PHPUnit_Framework_TestCase {
array('pubdate:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'),
array('pubdate:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'),
array('pubdate:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'),
- array('pubdate:2007-03-01/2008-05-11', '1172725200', '1210564799'),
- array('pubdate:2007-03-01/', '1172725200', ''),
- array('pubdate:/2008-05-11', '', '1210564799'),
+ 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),
);
}
@@ -201,7 +202,7 @@ class SearchTest extends \PHPUnit_Framework_TestCase {
public function provideTagsSearch() {
return array(
array('#word1', array('word1'), null),
- array('# word1', null, array('#', 'word1')),
+ array('# word1', array(), array('#', 'word1')),
array('#123', array('123'), null),
array('#word1 word2', array('word1'), array('word2')),
array('#"word1 word2"', array('"word1'), array('word2"')),
@@ -241,49 +242,49 @@ class SearchTest extends \PHPUnit_Framework_TestCase {
return array(
array(
'author:word1 date:2007-03-01/2008-05-11 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 #word5',
- 'word1',
- '1172725200',
- '1210564799',
- 'word2',
- 'word3',
- '1172725200',
- '1210564799',
+ array('word1'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
+ array('word2'),
+ array('word3'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
array('word4', 'word5'),
null,
),
array(
'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 date:2007-03-01/2008-05-11',
- 'word1',
- '1172725200',
- '1210564799',
- 'word2',
- 'word3',
- '1172725200',
- '1210564799',
+ array('word1'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
+ array('word2'),
+ array('word3'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
array('word4', 'word5'),
array('word6'),
),
array(
'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 word7 date:2007-03-01/2008-05-11',
- 'word1',
- '1172725200',
- '1210564799',
- 'word2',
- 'word3',
- '1172725200',
- '1210564799',
+ array('word1'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
+ array('word2'),
+ array('word3'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
array('word4', 'word5'),
array('word6', 'word7'),
),
array(
'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 "word7 word8" date:2007-03-01/2008-05-11',
- 'word1',
- '1172725200',
- '1210564799',
- 'word2',
- 'word3',
- '1172725200',
- '1210564799',
+ array('word1'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
+ array('word2'),
+ array('word3'),
+ strtotime('2007-03-01'),
+ strtotime('2008-05-12') - 1,
array('word4', 'word5'),
array('word7 word8', 'word6'),
),
diff --git a/tests/app/Models/UserQueryTest.php b/tests/app/Models/UserQueryTest.php
index a0928d5ae..5c12a12fc 100644
--- a/tests/app/Models/UserQueryTest.php
+++ b/tests/app/Models/UserQueryTest.php
@@ -3,7 +3,7 @@
/**
* Description of UserQueryTest
*/
-class UserQueryTest extends \PHPUnit_Framework_TestCase {
+class UserQueryTest extends PHPUnit\Framework\TestCase {
public function test__construct_whenAllQuery_storesAllParameters() {
$query = array('get' => 'a');