From fe7d9bbcd68660a59b813346c236b61b25a51c80 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 11 May 2023 12:53:32 +0200 Subject: Typed view model classes (#5380) * Typed view model classes * Add ability to provide a typed view model class to a controller * Use `::class` instead of string for referring to classes * Examplified with `stats` and `javascript` controllers / views (more to do) * Also useful for extensions (my usecase today), which did not have the ability to define own view model attributes before. * Typo --- tests/app/Models/UserQueryTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/app/Models/UserQueryTest.php b/tests/app/Models/UserQueryTest.php index d8610a81b..c227024a9 100644 --- a/tests/app/Models/UserQueryTest.php +++ b/tests/app/Models/UserQueryTest.php @@ -30,13 +30,13 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function test__construct_whenCategoryQuery_storesCategoryParameters(): void { $category_name = 'some category name'; /** @var FreshRSS_Category&PHPUnit\Framework\MockObject\MockObject */ - $cat = $this->createMock('FreshRSS_Category'); + $cat = $this->createMock(FreshRSS_Category::class); $cat->expects($this->atLeastOnce()) ->method('name') ->withAnyParameters() ->willReturn($category_name); /** @var FreshRSS_CategoryDAO&PHPUnit\Framework\MockObject\MockObject */ - $cat_dao = $this->createMock('FreshRSS_CategoryDAO'); + $cat_dao = $this->createMock(FreshRSS_CategoryDAO::class); $cat_dao->expects($this->atLeastOnce()) ->method('searchById') ->withAnyParameters() @@ -58,13 +58,13 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function test__construct_whenFeedQuery_storesFeedParameters(): void { $feed_name = 'some feed name'; /** @var FreshRSS_Feed&PHPUnit\Framework\MockObject\MockObject */ - $feed = $this->createMock('FreshRSS_Feed'); + $feed = $this->createMock(FreshRSS_Feed::class); $feed->expects($this->atLeastOnce()) ->method('name') ->withAnyParameters() ->willReturn($feed_name); /** @var FreshRSS_FeedDAO&PHPUnit\Framework\MockObject\MockObject */ - $feed_dao = $this->createMock('FreshRSS_FeedDAO'); + $feed_dao = $this->createMock(FreshRSS_FeedDAO::class); $feed_dao->expects($this->atLeastOnce()) ->method('searchById') ->withAnyParameters() @@ -164,9 +164,9 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testIsDeprecated_whenCategoryExists_returnFalse(): void { /** @var FreshRSS_Category&PHPUnit\Framework\MockObject\MockObject */ - $cat = $this->createMock('FreshRSS_Category'); + $cat = $this->createMock(FreshRSS_Category::class); /** @var FreshRSS_CategoryDAO&PHPUnit\Framework\MockObject\MockObject */ - $cat_dao = $this->createMock('FreshRSS_CategoryDAO'); + $cat_dao = $this->createMock(FreshRSS_CategoryDAO::class); $cat_dao->expects($this->atLeastOnce()) ->method('searchById') ->withAnyParameters() @@ -178,7 +178,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testIsDeprecated_whenCategoryDoesNotExist_returnTrue(): void { /** @var FreshRSS_CategoryDAO&PHPUnit\Framework\MockObject\MockObject */ - $cat_dao = $this->createMock('FreshRSS_CategoryDAO'); + $cat_dao = $this->createMock(FreshRSS_CategoryDAO::class); $cat_dao->expects($this->atLeastOnce()) ->method('searchById') ->withAnyParameters() @@ -190,9 +190,9 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testIsDeprecated_whenFeedExists_returnFalse(): void { /** @var FreshRSS_Feed&PHPUnit\Framework\MockObject\MockObject */ - $feed = $this->createMock('FreshRSS_Feed'); + $feed = $this->createMock(FreshRSS_Feed::class); /** @var FreshRSS_FeedDAO&PHPUnit\Framework\MockObject\MockObject */ - $feed_dao = $this->createMock('FreshRSS_FeedDAO'); + $feed_dao = $this->createMock(FreshRSS_FeedDAO::class); $feed_dao->expects($this->atLeastOnce()) ->method('searchById') ->withAnyParameters() @@ -204,7 +204,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testIsDeprecated_whenFeedDoesNotExist_returnTrue(): void { /** @var FreshRSS_FeedDAO&PHPUnit\Framework\MockObject\MockObject */ - $feed_dao = $this->createMock('FreshRSS_FeedDAO'); + $feed_dao = $this->createMock(FreshRSS_FeedDAO::class); $feed_dao->expects($this->atLeastOnce()) ->method('searchById') ->withAnyParameters() -- cgit v1.2.3