-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkp/pkp-lib#10306 unit tests for queue jobs #10340
base: main
Are you sure you want to change the base?
Conversation
d670e83
to
2fd4f04
Compare
if (PKPContainer::getInstance()->runningUnitTests()) { | ||
$client = Registry::get(\PKP\tests\PKPTestCase::MOCKED_GUZZLE_CLIENT_NAME); | ||
if ($client) { | ||
return $client; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
part of functionality to mocking ability for guzzel request .
@@ -56,7 +56,7 @@ public function updateNotification(PKPRequest $request, ?array $userIds, int $as | |||
* | |||
* @copydoc PKPNotificationOperationManager::createNotification() | |||
*/ | |||
public function createNotification(PKPRequest $request, ?int $userId = null, ?int $notificationType = null, ?int $contextId = Application::SITE_CONTEXT_ID, ?int $assocType = null, ?int $assocId = null, int $level = Notification::NOTIFICATION_LEVEL_NORMAL, ?array $params = null): ?Notification | |||
public function createNotification(?PKPRequest $request = null, ?int $userId = null, ?int $notificationType = null, ?int $contextId = Application::SITE_CONTEXT_ID, ?int $assocType = null, ?int $assocId = null, int $level = Notification::NOTIFICATION_LEVEL_NORMAL, ?array $params = null): ?Notification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have any use of PKPRequest $request
here as it seems this data not used ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right -- this parameter can be removed.
tests/PKPTestCase.php
Outdated
@@ -205,8 +220,7 @@ protected function mockRequest($path = 'index/test-page/test-op', $userId = null | |||
$request->setRouter($router); | |||
|
|||
// Test user. | |||
$session = $request->getSession(); | |||
$session->setUserId($userId); | |||
$request->getSessionGuard()->setUserId($userId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a leftover missing change from #9566
$bulkEmailSenderJob->handle(); | ||
|
||
$this->expectNotToPerformAssertions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our previous asserting was like $this->assertNull($bulkEmailSenderJob->handle())
. However the handle
method return type set as void
which does turn in null and older PHPUnit version did not have a arg type defined . But the latest PHPUnit version has arg type define as mixed
which in turn identified as error as return type void
does not match with arg time mixed
. Though this does not cause exception but modern IDEs identify it as error . So probably better to go with approach here and all other places .
6677802
to
f3083e3
Compare
* Override Laravel method; always false. | ||
* Prevents the undefined method error when the Log Manager tries to determine the driver | ||
*/ | ||
public function runningUnitTests(): bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be removed once we add and configure the Laravel logging service provider, correct? I think this is related to what you're talking about with Erik. It might be worth filing in Github, noting this function in the issue, and adding a FIXME here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly , this has there before this PR and probably will stay . Our Container class extends the laravel core container but We have our very own Application class . Once we able to handle the bootstrapping process to Laravel's foundation Application, we can remove this (as it's reside there) . As few core class required this information, so we have copied it from Laravel's foundation application class to our PKPContainer just to facilitate the dependency.
tests/PKPTestCase.php
Outdated
|
||
/** | ||
* Mock the mail facade | ||
* @see https://laravel.com/docs/10.x/mocking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to link to 11, since that's what we're shipping.
/** @var NewAnnouncementNotifyUsers $newAnnouncementNotifyUsersJob */ | ||
$newAnnouncementNotifyUsersJob = unserialize($this->serializedJobData); | ||
|
||
$announcementMock = Mockery::mock(\PKP\announcement\Announcement::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to require some work once #10328 is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor suggestions -- thanks, @touhidurabir!
120f66a
to
2cad824
Compare
4379792
to
2dd338f
Compare
3ef1876
to
1a7bdf8
Compare
for #10306