aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-04 13:30:45 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-04 13:30:45 +0100
commitb3239256dc6d188cda970adab516b3fcf1b86129 (patch)
treed8e65dd9784834ba2e82ce7ee94b4718f8af19ea /tests
parent27b71ffa99f7dff013fb8d51d020ed628e0d2ce6 (diff)
parent0fe0ce894cbad09757d719dd4b400b9862c1a12a (diff)
Merge branch 'edge' into latest
Diffstat (limited to 'tests')
-rw-r--r--tests/app/Models/CategoryTest.php50
-rw-r--r--tests/app/Models/SearchTest.php13
-rw-r--r--tests/app/Models/UserQueryTest.php20
3 files changed, 69 insertions, 14 deletions
diff --git a/tests/app/Models/CategoryTest.php b/tests/app/Models/CategoryTest.php
index e4a921baa..93fbdbc63 100644
--- a/tests/app/Models/CategoryTest.php
+++ b/tests/app/Models/CategoryTest.php
@@ -30,4 +30,54 @@ class CategoryTest extends PHPUnit\Framework\TestCase {
);
}
+ public function test_feedOrdering() {
+ $feed_1 = $this->getMockBuilder(FreshRSS_Feed::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $feed_1->expects($this->any())
+ ->method('name')
+ ->willReturn('AAA');
+
+ $feed_2 = $this->getMockBuilder(FreshRSS_Feed::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $feed_2->expects($this->any())
+ ->method('name')
+ ->willReturn('ZZZ');
+
+ $feed_3 = $this->getMockBuilder(FreshRSS_Feed::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $feed_3->expects($this->any())
+ ->method('name')
+ ->willReturn('lll');
+
+ $category = new FreshRSS_Category('test', [
+ $feed_1,
+ $feed_2,
+ $feed_3,
+ ]);
+ $feeds = $category->feeds();
+
+ $this->assertCount(3, $feeds);
+ $this->assertEquals('AAA', $feeds[0]->name());
+ $this->assertEquals('lll', $feeds[1]->name());
+ $this->assertEquals('ZZZ', $feeds[2]->name());
+
+ $feed_4 = $this->getMockBuilder(FreshRSS_Feed::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $feed_4->expects($this->any())
+ ->method('name')
+ ->willReturn('BBB');
+
+ $category->addFeed($feed_4);
+ $feeds = $category->feeds();
+
+ $this->assertCount(4, $feeds);
+ $this->assertEquals('AAA', $feeds[0]->name());
+ $this->assertEquals('BBB', $feeds[1]->name());
+ $this->assertEquals('lll', $feeds[2]->name());
+ $this->assertEquals('ZZZ', $feeds[3]->name());
+ }
}
diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php
index a2832c710..52c10244d 100644
--- a/tests/app/Models/SearchTest.php
+++ b/tests/app/Models/SearchTest.php
@@ -318,17 +318,17 @@ class SearchTest extends PHPUnit\Framework\TestCase {
],
[
'#tag Hello OR (author:Alice inurl:example) OR (f:3 intitle:World) OR L:12',
- ' ((e.tags LIKE ? AND (e.title LIKE ? OR e.content LIKE ?) )) OR ((e.author LIKE ? AND e.link LIKE ? )) OR' .
+ " ((TRIM(e.tags) || ' #' LIKE ? AND (e.title LIKE ? OR e.content LIKE ?) )) OR ((e.author LIKE ? AND e.link LIKE ? )) OR" .
' ((e.id_feed IN (?) AND e.title LIKE ? )) OR ((e.id IN (SELECT et.id_entry FROM `_entrytag` et WHERE et.id_tag IN (?)) )) ',
- ['%tag%','%Hello%', '%Hello%', '%Alice%', '%example%', '3', '%World%', '12']
+ ['%tag #%','%Hello%', '%Hello%', '%Alice%', '%example%', '3', '%World%', '12']
],
[
'#tag Hello (author:Alice inurl:example) (f:3 intitle:World) label:Bleu',
- ' ((e.tags LIKE ? AND (e.title LIKE ? OR e.content LIKE ?) )) AND' .
+ " ((TRIM(e.tags) || ' #' LIKE ? AND (e.title LIKE ? OR e.content LIKE ?) )) AND" .
' ((e.author LIKE ? AND e.link LIKE ? )) AND' .
' ((e.id_feed IN (?) AND e.title LIKE ? )) AND' .
' ((e.id IN (SELECT et.id_entry FROM `_entrytag` et, `_tag` t WHERE et.id_tag = t.id AND t.name IN (?)) )) ',
- ['%tag%', '%Hello%', '%Hello%', '%Alice%', '%example%', '3', '%World%', 'Bleu']
+ ['%tag #%', '%Hello%', '%Hello%', '%Alice%', '%example%', '3', '%World%', 'Bleu']
],
[
'!((author:Alice intitle:hello) OR (author:Bob intitle:world))',
@@ -339,6 +339,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {
'(author:Alice intitle:hello) !(author:Bob intitle:world)',
' ((e.author LIKE ? AND e.title LIKE ? )) AND NOT ((e.author LIKE ? AND e.title LIKE ? )) ',
['%Alice%', '%hello%', '%Bob%', '%world%'],
+ ],
+ [
+ 'intitle:"\\(test\\)"',
+ '(e.title LIKE ? )',
+ ['%\\(test\\)%'],
]
];
}
diff --git a/tests/app/Models/UserQueryTest.php b/tests/app/Models/UserQueryTest.php
index c876740e6..7b1e88907 100644
--- a/tests/app/Models/UserQueryTest.php
+++ b/tests/app/Models/UserQueryTest.php
@@ -34,7 +34,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
->method('name')
->withAnyParameters()
->willReturn($category_name);
- $cat_dao = $this->createMock('FreshRSS_Searchable');
+ $cat_dao = $this->createMock('FreshRSS_CategoryDAO');
$cat_dao->expects($this->atLeastOnce())
->method('searchById')
->withAnyParameters()
@@ -60,7 +60,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
->method('name')
->withAnyParameters()
->willReturn($feed_name);
- $feed_dao = $this->createMock('FreshRSS_Searchable');
+ $feed_dao = $this->createMock('FreshRSS_FeedDAO');
$feed_dao->expects($this->atLeastOnce())
->method('searchById')
->withAnyParameters()
@@ -74,8 +74,8 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
public function test__construct_whenUnknownQuery_doesStoreParameters() {
$query = array('get' => 'q');
$user_query = new FreshRSS_UserQuery($query);
- $this->assertNull($user_query->getGetName());
- $this->assertNull($user_query->getGetType());
+ $this->assertEmpty($user_query->getGetName());
+ $this->assertEmpty($user_query->getGetType());
}
public function test__construct_whenName_storesName() {
@@ -93,7 +93,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
}
public function test__construct_whenState_storesState() {
- $state = 'some state';
+ $state = FreshRSS_Entry::STATE_ALL;
$query = array('state' => $state);
$user_query = new FreshRSS_UserQuery($query);
$this->assertEquals($state, $user_query->getState());
@@ -118,7 +118,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
'name' => 'some name',
'order' => 'some order',
'search' => 'some search',
- 'state' => 'some state',
+ 'state' => FreshRSS_Entry::STATE_ALL,
'url' => 'some url',
);
$user_query = new FreshRSS_UserQuery($query);
@@ -160,7 +160,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
public function testIsDeprecated_whenCategoryExists_returnFalse() {
$cat = $this->createMock('FreshRSS_Category');
- $cat_dao = $this->createMock('FreshRSS_Searchable');
+ $cat_dao = $this->createMock('FreshRSS_CategoryDAO');
$cat_dao->expects($this->atLeastOnce())
->method('searchById')
->withAnyParameters()
@@ -171,7 +171,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
}
public function testIsDeprecated_whenCategoryDoesNotExist_returnTrue() {
- $cat_dao = $this->createMock('FreshRSS_Searchable');
+ $cat_dao = $this->createMock('FreshRSS_CategoryDAO');
$cat_dao->expects($this->atLeastOnce())
->method('searchById')
->withAnyParameters()
@@ -183,7 +183,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
public function testIsDeprecated_whenFeedExists_returnFalse() {
$feed = $this->createMock('FreshRSS_Feed', array(), array('', false));
- $feed_dao = $this->createMock('FreshRSS_Searchable');
+ $feed_dao = $this->createMock('FreshRSS_FeedDAO');
$feed_dao->expects($this->atLeastOnce())
->method('searchById')
->withAnyParameters()
@@ -194,7 +194,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase {
}
public function testIsDeprecated_whenFeedDoesNotExist_returnTrue() {
- $feed_dao = $this->createMock('FreshRSS_Searchable');
+ $feed_dao = $this->createMock('FreshRSS_FeedDAO');
$feed_dao->expects($this->atLeastOnce())
->method('searchById')
->withAnyParameters()