diff options
Diffstat (limited to 'tests/app/Models')
| -rw-r--r-- | tests/app/Models/CategoryTest.php | 5 | ||||
| -rw-r--r-- | tests/app/Models/UserQueryTest.php | 15 |
2 files changed, 15 insertions, 5 deletions
diff --git a/tests/app/Models/CategoryTest.php b/tests/app/Models/CategoryTest.php index 70bed7477..0290b6b61 100644 --- a/tests/app/Models/CategoryTest.php +++ b/tests/app/Models/CategoryTest.php @@ -33,6 +33,7 @@ class CategoryTest extends PHPUnit\Framework\TestCase { $feed_1 = $this->getMockBuilder(FreshRSS_Feed::class) ->disableOriginalConstructor() ->getMock(); + $feed_1->method('id')->withAnyParameters()->willReturn(1); $feed_1->expects(self::any()) ->method('name') ->willReturn('AAA'); @@ -40,6 +41,7 @@ class CategoryTest extends PHPUnit\Framework\TestCase { $feed_2 = $this->getMockBuilder(FreshRSS_Feed::class) ->disableOriginalConstructor() ->getMock(); + $feed_2->method('id')->withAnyParameters()->willReturn(2); $feed_2->expects(self::any()) ->method('name') ->willReturn('ZZZ'); @@ -47,6 +49,7 @@ class CategoryTest extends PHPUnit\Framework\TestCase { $feed_3 = $this->getMockBuilder(FreshRSS_Feed::class) ->disableOriginalConstructor() ->getMock(); + $feed_3->method('id')->withAnyParameters()->willReturn(3); $feed_3->expects(self::any()) ->method('name') ->willReturn('lll'); @@ -70,9 +73,11 @@ class CategoryTest extends PHPUnit\Framework\TestCase { $feed_4 = $this->getMockBuilder(FreshRSS_Feed::class) ->disableOriginalConstructor() ->getMock(); + $feed_4->method('id')->withAnyParameters()->willReturn(4); $feed_4->expects(self::any()) ->method('name') ->willReturn('BBB'); + $feed_4->method('id')->withAnyParameters()->willReturn(5); $category->addFeed($feed_4); $feeds = $category->feeds(); diff --git a/tests/app/Models/UserQueryTest.php b/tests/app/Models/UserQueryTest.php index 04fb74fd0..3017f7897 100644 --- a/tests/app/Models/UserQueryTest.php +++ b/tests/app/Models/UserQueryTest.php @@ -23,12 +23,13 @@ class UserQueryTest extends TestCase { $category_name = 'some category name'; /** @var FreshRSS_Category&PHPUnit\Framework\MockObject\MockObject */ $cat = $this->createMock(FreshRSS_Category::class); + $cat->method('id')->withAnyParameters()->willReturn(1); $cat->expects(self::atLeastOnce()) ->method('name') ->withAnyParameters() ->willReturn($category_name); $query = ['get' => 'c_1']; - $user_query = new FreshRSS_UserQuery($query, [1 => $cat], []); + $user_query = new FreshRSS_UserQuery($query, [$cat], []); self::assertSame($category_name, $user_query->getGetName()); self::assertSame('category', $user_query->getGetType()); } @@ -47,12 +48,13 @@ class UserQueryTest extends TestCase { ->willReturn($feed_name); /** @var FreshRSS_Category&PHPUnit\Framework\MockObject\MockObject */ $cat = $this->createMock(FreshRSS_Category::class); + $cat->method('id')->withAnyParameters()->willReturn(1); $cat->expects(self::atLeastOnce()) ->method('feeds') ->withAnyParameters() ->willReturn([1 => $feed]); $query = ['get' => 'f_1']; - $user_query = new FreshRSS_UserQuery($query, [1 => $cat], []); + $user_query = new FreshRSS_UserQuery($query, [$cat], []); self::assertSame($feed_name, $user_query->getGetName()); self::assertSame('feed', $user_query->getGetType()); } @@ -143,12 +145,13 @@ class UserQueryTest extends TestCase { public function testIsDeprecated_whenCategoryExists_returnFalse(): void { /** @var FreshRSS_Category&PHPUnit\Framework\MockObject\MockObject */ $cat = $this->createMock(FreshRSS_Category::class); + $cat->method('id')->withAnyParameters()->willReturn(1); $cat->expects(self::atLeastOnce()) ->method('name') ->withAnyParameters() ->willReturn('cat 1'); $query = ['get' => 'c_1']; - $user_query = new FreshRSS_UserQuery($query, [1 => $cat], []); + $user_query = new FreshRSS_UserQuery($query, [$cat], []); self::assertFalse($user_query->isDeprecated()); } @@ -171,24 +174,26 @@ class UserQueryTest extends TestCase { ->willReturn('feed 1'); /** @var FreshRSS_Category&PHPUnit\Framework\MockObject\MockObject */ $cat = $this->createMock(FreshRSS_Category::class); + $cat->method('id')->withAnyParameters()->willReturn(1); $cat->expects(self::atLeastOnce()) ->method('feeds') ->withAnyParameters() ->willReturn([1 => $feed]); $query = ['get' => 'f_1']; - $user_query = new FreshRSS_UserQuery($query, [1 => $cat], []); + $user_query = new FreshRSS_UserQuery($query, [$cat], []); self::assertFalse($user_query->isDeprecated()); } public function testIsDeprecated_whenFeedDoesNotExist_returnTrue(): void { /** @var FreshRSS_Category&PHPUnit\Framework\MockObject\MockObject */ $cat = $this->createMock(FreshRSS_Category::class); + $cat->method('id')->withAnyParameters()->willReturn(1); $cat->expects(self::atLeastOnce()) ->method('feeds') ->withAnyParameters() ->willReturn([]); $query = ['get' => 'f_1']; - $user_query = new FreshRSS_UserQuery($query, [1 => $cat], []); + $user_query = new FreshRSS_UserQuery($query, [$cat], []); self::assertTrue($user_query->isDeprecated()); } |
