diff options
author | Robin Appelman <robin@icewind.nl> | 2018-06-08 02:04:04 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-06-08 14:51:31 +0300 |
commit | 634469aaca82368b0d3d76a48de9812429e8a9cf (patch) | |
tree | b4908ba3c3615a958b52b61003ad8ff4ea28ee9e /tests | |
parent | ce8944db38a36a7fa879a0b1206651b72398e40c (diff) |
Add support for basic "advanced search"
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/SearchHelperTest.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/SearchHelperTest.php b/tests/SearchHelperTest.php new file mode 100644 index 000000000..97fb4018e --- /dev/null +++ b/tests/SearchHelperTest.php @@ -0,0 +1,57 @@ +<?php +/** + * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Mail\Tests; + +use ChristophWurst\Nextcloud\Testing\TestCase; +use OCA\Mail\SearchHelper; + +class SearchHelperTest extends TestCase { + private function search($filter) { + $helper = new SearchHelper(); + $query = $helper->parseFilterString($filter); + return (string)($query->build()['query']); + } + + public function testSearchEmpty() { + $this->assertEquals('ALL', $this->search('')); + } + + public function testSearchTest() { + $this->assertEquals('TEXT "dummy text"', $this->search('dummy text')); + } + + public function testSearchUnread() { + $this->assertEquals('UNSEEN', $this->search('is:unread')); + } + + public function testSearchNotAnswered() { + $this->assertEquals('UNANSWERED', $this->search('not:answered')); + } + + public function testSearchFrom() { + $this->assertEquals('FROM somebody@example.com', $this->search('from:somebody@example.com')); + } + + public function testSearchMixed() { + $this->assertEquals('UNSEEN FROM somebody@example.com TEXT nextcloud', $this->search('from:somebody@example.com is:unread nextcloud')); + } +} |