diff options
| author | 2023-03-04 13:30:45 +0100 | |
|---|---|---|
| committer | 2023-03-04 13:30:45 +0100 | |
| commit | b3239256dc6d188cda970adab516b3fcf1b86129 (patch) | |
| tree | d8e65dd9784834ba2e82ce7ee94b4718f8af19ea /tests/app/Models/CategoryTest.php | |
| parent | 27b71ffa99f7dff013fb8d51d020ed628e0d2ce6 (diff) | |
| parent | 0fe0ce894cbad09757d719dd4b400b9862c1a12a (diff) | |
Merge branch 'edge' into latest
Diffstat (limited to 'tests/app/Models/CategoryTest.php')
| -rw-r--r-- | tests/app/Models/CategoryTest.php | 50 |
1 files changed, 50 insertions, 0 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()); + } } |
