pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
304 stars 444 forks source link

Add unit test for each queue jobs class #9899

Open touhidurabir opened 5 months ago

touhidurabir commented 5 months ago

Describe the problem Starting from 3.4.0 we have queue jobs to handle long running tasks or for tasks that need to done later . Our queue jobs implementation is an extended implementation of Laravel queue jobs.

The problem arise or will arise when any of the jobs structure will update but there is one or more pending jobs with older structure already dispatched in queue waiting to get executed . This problem get more complex with the upgrade of newer version when older structure based job still in queue as they may continue to fail and no way to resolve it after upgrade which may lead to undesirable outcome.

Describe the proposal The initial plan was to force to run all pending queue jobs before upgrade which proposed at Add pre-flight check for pending jobs before running upgrade . This was a very simple and easy approach but may not suited for all possible cases . Also a job class structure or handle implementation may need to update based on requirement.

After some detailed discussion, we decided to add unit tests for each job class to make sure the consistence update the job class structure and handle method implementation . The idea is to try to mock each of jobs class to make sure it's on even after any update to it.

Impacted version OJS, OMP or OPS version 3.4.0 and main

Additional information Details discussion at Right approach to handle pending queue jobs at upgrade

Job classes to have unit tests

Stable-3.4.0

OJS

PRs (Merged) pkp-lib --> https://github.com/pkp/pkp-lib/pull/9981 ojs --> https://github.com/pkp/ojs/pull/4285 omp --> https://github.com/pkp/omp/pull/1666 ops --> https://github.com/pkp/ops/pull/745

PR Patch pkp-lib --> https://github.com/pkp/pkp-lib/pull/10368 ojs --> https://github.com/pkp/ojs/pull/4426 ops --> https://github.com/pkp/ops/pull/763 omp --> https://github.com/pkp/omp/pull/1693

touhidurabir commented 3 months ago

@asmecher can you take a look the PR at https://github.com/pkp/pkp-lib/issues/9899#issue-2252485770 for the OJS only ?

touhidurabir commented 3 months ago

@withanage can you please take a look at this particular implementation to mock the Guzzle Http Client for unit tests .

implementation of mock at PKPTestCase and to facilitate it , I had to add few logic within the core app at PKPApplication and PKPContainer.

Long story short, we like to mock the guzzle requests without making any actual request but our very static like Application::get()->getHttpClient() implementation kind of make it very hard to mock it . Me and @asmecher was discussing about it and we would like to get your suggestion and advice on this as I am not very happy with this implementation but at the same time could not figure out any better approach .

We can also decide not to mock it for 3.4.0 and have something better like Laravel Http in 3.5. But that means either we have to ditch those specific queue job classes unit test or have unit test and allow hitting real url, both option does not seems very best.

Also any suggestion or advise on approach on the job test implementation are welcomed .

withanage commented 3 months ago

Hi @touhidurabir

PKPTestCase

I have looked at your test. I also think that the way you have implmented, it is the best possible way to mock the Guzzle HTTP client and I can't offer a better approach either.

General support

asmecher commented 3 months ago

@touhidurabir, for some reason your .php additions in https://github.com/pkp/ojs/pull/4285/files are being flagged as binary by Github; is there some unusual encoding or something causing this?

asmecher commented 3 months ago

@touhidurabir, for some reason your .php additions in https://github.com/pkp/ojs/pull/4285/files are being flagged as binary by Github; is there some unusual encoding or something causing this?

^ I suspect it's the ^@*^@ part of the serialized object. I suppose we could prevent that from happening using base64 or chr or something, but I don't know if it's a problem worth solving; I'm OK to ignore it.

touhidurabir commented 3 months ago

@asmecher I just noticed the issue in github as it is not causing any issue for me in my editor(VS code or sublime) . I think we can easily solve it using the base64 encode/decode. At least anyone one can see the test file but wont be able to understand the what props are defined there with a single look as base64 encoded string .

I think it's worth solving and will only take about an hour or two to update all the tests . for me it's not causing any issue in my editor but may cause issue with different editor for other .

touhidurabir commented 3 months ago

@asmecher I have updated the tests to resolve the binary file issue . Good to take a look now .

asmecher commented 2 months ago

Sorry for the wait, @touhidurabir! I added a comment about that: https://github.com/pkp/ojs/pull/4285#pullrequestreview-2187026948

asmecher commented 1 month ago

@touhidurabir, this looks good, thanks -- just one file still being classified as binary. Once that's resolved, please go ahead and merge!

asmecher commented 1 month ago

All PRs merged -- is anything else required on this issue, @touhidurabir?

touhidurabir commented 1 month ago

@asmecher nothing more required for this . for 3.5 we can have different issue to add unit tests for queue jobs .

touhidurabir commented 1 month ago

@asmecher I am re-opening this issue as our github action was not running any job unit tests and it seems some pkp-lib jobs which runs fine for OJS are failing for both the OPS and OMP .

I have registered an issue for github action at https://github.com/pkp/pkp-github-actions/issues/68 . PR done but need to wait to merge till unit tests failing issue get fixed first .

touhidurabir commented 3 weeks ago

@asmecher All testes update . Please take a look at https://github.com/pkp/pkp-lib/issues/9899#issue-225248577, section PR Patch . The tests are ok in local testing for both pkp-lib and app specific for all apps .

asmecher commented 2 weeks ago

@touhidurabir, I have a few problems running the tests from the PRs above with OJS stable-3_4_0, with both the ojs and pkp-lib repos coming from your branches:

  1. I get deprecation errors through PHPUnit:
    ├ PHP Deprecated:  htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /home/asmecher/git/ojs-stable-3_4_0/classes/mail/variables/ContextEmailVariable.php on line 49                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
    ├ PHP Stack trace:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    ├ PHP   1. {main}() Standard input code:0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    ├ PHP   2. __phpunit_run_isolated_test() Standard input code:924                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
    ├ PHP   3. PHPUnit\Framework\TestCase->run($result = class PHPUnit\Framework\TestResult { private $passed = []; private $passedTestClasses = []; private $currentTestSuiteFailed = FALSE; private $errors = []; private $failures = []; private $warnings = []; private $notImplemented = []; private $risky = []; private $skipped = []; private $listeners = []; private $runTests = 1; private $time = 0; private $codeCoverage = NULL; private $convertDeprecationsToExceptions = FALSE; private $convertErrorsToExceptions = TRUE; private $convertNoticesToExceptions = TRUE; private $convertWarningsToExceptions = TRUE; private $stop = FALSE; private $stopOnError = FALSE; private $stopOnFailure = FALSE; private $stopOnWarning = FALSE; private $beStrictAboutTestsThatDoNotTestAnything = TRUE; private $beStrictAboutOutputDuringTests = TRUE; private $beStrictAboutTodoAnnotatedTests = FALSE; private $beStrictAboutResourceUsageDuringSmallTests = FALSE; private $enforceTimeLimit = FALSE; private $forceCoversAnnotation = FALSE; private $timeoutForSmallTests = 1; private $timeoutForMediumTests = 10; private $timeoutForLargeTests = 60; private $stopOnRisky = FALSE; private $stopOnIncomplete = FALSE; private $stopOnSkipped = FALSE; private $lastTestFailed = FALSE; private $defaultTimeLimit = 0; private $stopOnDefect = FALSE; private $registerMockObjectsFromTestArgumentsRecursively = FALSE }) Standard input code:424                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
    ├ PHP   4. PHPUnit\Framework\TestResult->run($test = class PKP\tests\jobs\notifications\NewAnnouncementNotifyUsersTest { protected $backupGlobals = TRUE; protected $backupGlobalsExcludeList = []; protected $backupGlobalsBlacklist = []; protected $backupStaticAttributes = NULL; protected $backupStaticAttributesExcludeList = []; protected $backupStaticAttributesBlacklist = []; protected $runTestInSeparateProcess = NULL; protected $preserveGlobalState = TRUE; protected $providedTests = [0 => class PHPUnit\Framework\ExecutionOrderDependency { ... }]; private ${PHPUnit\Framework\TestCase}runClassInSeparateProcess = NULL; private ${PHPUnit\Framework\TestCase}inIsolation = TRUE; private ${PHPUnit\Framework\TestCase}data = []; private ${PHPUnit\Framework\TestCase}dataName = ''; private ${PHPUnit\Framework\TestCase}expectedException = NULL; private ${PHPUnit\Framework\TestCase}expectedExceptionMessage = NULL; private ${PHPUnit\Framework\TestCase}expectedExceptionMessageRegExp = NULL; private ${PHPUnit\Framework\TestCase}expectedExceptionCode = NULL; private ${PHPUnit\Framework\TestCase}name = 'testRunSerializedJob'; private ${PHPUnit\Framework\TestCase}dependencies = []; private ${PHPUnit\Framework\TestCase}dependencyInput = []; private ${PHPUnit\Framework\TestCase}iniSettings = []; private ${PHPUnit\Framework\TestCase}locale = []; private ${PHPUnit\Framework\TestCase}mockObjects = []; private ${PHPUnit\Framework\TestCase}mockObjectGenerator = NULL; private ${PHPUnit\Framework\TestCase}status = -1; private ${PHPUnit\Framework\TestCase}statusMessage = ''; private ${PHPUnit\Framework\TestCase}numAssertions = 0; private ${PHPUnit\Framework\TestCase}result = class PHPUnit\Framework\TestResult { private $passed = [...]; private $passedTestClasses = [...]; private $currentTestSuiteFailed = FALSE; private $errors = [...]; private $failures = [...]; private $warnings = [...]; private $notImplemented = [...]; private $risky = [...]; private $skipped = [...]; private $listeners = [...]; private $runTests = 1; private $time = 0; private $codeCoverage = NULL; private $convertDeprecationsToExceptions = FALSE; private $convertErrorsToExceptions = TRUE; private $convertNoticesToExceptions = TRUE; private $convertWarningsToExceptions = TRUE; private $stop = FALSE; private $stopOnError = FALSE; private $stopOnFailure = FALSE; private $stopOnWarning = FALSE; private $beStrictAboutTestsThatDoNotTestAnything = TRUE; private $beStrictAboutOutputDuringTests = TRUE; private $beStrictAboutTodoAnnotatedTests = FALSE; private $beStrictAboutResourceUsageDuringSmallTests = FALSE; private $enforceTimeLimit = FALSE; private $forceCoversAnnotation = FALSE; private $timeoutForSmallTests = 1; private $timeoutForMediumTests = 10; private $timeoutForLargeTests = 60; private $stopOnRisky = FALSE; private $stopOnIncomplete = FALSE; private $stopOnSkipped = FALSE; private $lastTestFailed = FALSE; private $defaultTimeLimit = 0; private $stopOnDefect = FALSE; private $registerMockObjectsFromTestArgumentsRecursively = FALSE }; private ${PHPUnit\Framework\TestCase}testResult = NULL; private ${PHPUnit\Framework\TestCase}output = ''; private ${PHPUnit\Framework\TestCase}outputExpectedRegex = NULL; private ${PHPUnit\Framework\TestCase}outputExpectedString = NULL; private ${PHPUnit\Framework\TestCase}outputCallback = FALSE; private ${PHPUnit\Framework\TestCase}outputBufferingActive = TRUE; private ${PHPUnit\Framework\TestCase}outputBufferingLevel = 1; private ${PHPUnit\Framework\TestCase}outputRetrievedForAssertion = FALSE; private ${PHPUnit\Framework\TestCase}snapshot = NULL; private ${PHPUnit\Framework\TestCase}prophet = NULL; private ${PHPUnit\Framework\TestCase}beStrictAboutChangesToGlobalState = FALSE; private ${PHPUnit\Framework\TestCase}registerMockObjectsFromTestArgumentsRecursively = FALSE; private ${PHPUnit\Framework\TestCase}warnings = []; private ${PHPUnit\Framework\TestCase}groups = []; private ${PHPUnit\Framework\TestCase}doesNotPerformAssertions = FALSE; private ${PHPUnit\Framework\TestCase}customComparators = []; private ${PHPUnit\Framework\TestCase}doubledTypes = []; private array ${PKP\tests\PKPTestCase}daoBackup = []; private array ${PKP\tests\PKPTestCase}registryBackup = ['request' => NULL]; private array ${PKP\tests\PKPTestCase}containerBackup = []; private array ${PKP\tests\PKPTestCase}mockedRegistryKeys = [0 => 'request']; protected string $serializedJobData = 'O:49:"PKP\\jobs\\notifications\\NewAnnouncementNotifyUsers":7:{s:15:"\000*\000recipientIds";O:29:"Illuminate\\Support\\Collection":2:{s:8:"\000*\000items";a:3:{i:0;i:2;i:1;i:3;i:2;i:4;}s:28:"\000*\000escapeWhenCastingToString";b:0;}s:12:"\000*\000contextId";i:1;s:17:"\000*\000announcementId";i:1;s:9:"\000*\000locale";s:2:"en";s:9:"\000*\000sender";O:13:"PKP\\user\\User":7:{s:5:"_data";a:22:{s:2:"id";i:1;s:8:"userName";s:5:"admin";s:8:"password";s:60:"$2y$10$uFmYXg8/Ufa0HbskyW57Be22stFGY5qtxJZmTOae3PfDB86V3x7BW";s:5:"email";s:23:"pkpadmin@mailinator.com";s'... }) /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestCase.php:964
    ├ PHP   5. PHPUnit\Framework\TestCase->runBare() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestResult.php:728                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    ├ PHP   6. PHPUnit\Framework\TestCase->runTest() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestCase.php:1214                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    ├ PHP   7. PKP\tests\jobs\notifications\NewAnnouncementNotifyUsersTest->testRunSerializedJob() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestCase.php:1608                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    ├ PHP   8. PKP\jobs\notifications\NewAnnouncementNotifyUsers->handle() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/tests/jobs/notifications/NewAnnouncementNotifyUsersTest.php:125                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    ├ PHP   9. PKP\mail\mailables\AnnouncementNotify->setData($locale = 'en') /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/jobs/notifications/NewAnnouncementNotifyUsers.php:91                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    ├ PHP  10. PKP\mail\Mailable->setData($locale = 'en') /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/classes/mail/mailables/AnnouncementNotify.php:74                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    ├ PHP  11. APP\mail\variables\ContextEmailVariable->values($locale = 'en') /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/classes/mail/Mailable.php:234                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    ├ PHP  12. htmlspecialchars($string = NULL) /home/asmecher/git/ojs-stable-3_4_0/classes/mail/variables/ContextEmailVariable.php:49                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  2. The StatisticsReportMail job seems to hang after the following output:
    Statistics Report Mail (PKP\tests\jobs\notifications\StatisticsReportMail)
    ✔ Unserialization get proper job instance  4 ms
touhidurabir commented 1 week ago

@touhidurabir, I have a few problems running the tests from the PRs above with OJS stable-3_4_0, with both the ojs and pkp-lib repos coming from your branches:

  1. I get deprecation errors through PHPUnit:
  ├ PHP Deprecated:  htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /home/asmecher/git/ojs-stable-3_4_0/classes/mail/variables/ContextEmailVariable.php on line 49                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
   ├ PHP Stack trace:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
   ├ PHP   1. {main}() Standard input code:0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
   ├ PHP   2. __phpunit_run_isolated_test() Standard input code:924                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
   ├ PHP   3. PHPUnit\Framework\TestCase->run($result = class PHPUnit\Framework\TestResult { private $passed = []; private $passedTestClasses = []; private $currentTestSuiteFailed = FALSE; private $errors = []; private $failures = []; private $warnings = []; private $notImplemented = []; private $risky = []; private $skipped = []; private $listeners = []; private $runTests = 1; private $time = 0; private $codeCoverage = NULL; private $convertDeprecationsToExceptions = FALSE; private $convertErrorsToExceptions = TRUE; private $convertNoticesToExceptions = TRUE; private $convertWarningsToExceptions = TRUE; private $stop = FALSE; private $stopOnError = FALSE; private $stopOnFailure = FALSE; private $stopOnWarning = FALSE; private $beStrictAboutTestsThatDoNotTestAnything = TRUE; private $beStrictAboutOutputDuringTests = TRUE; private $beStrictAboutTodoAnnotatedTests = FALSE; private $beStrictAboutResourceUsageDuringSmallTests = FALSE; private $enforceTimeLimit = FALSE; private $forceCoversAnnotation = FALSE; private $timeoutForSmallTests = 1; private $timeoutForMediumTests = 10; private $timeoutForLargeTests = 60; private $stopOnRisky = FALSE; private $stopOnIncomplete = FALSE; private $stopOnSkipped = FALSE; private $lastTestFailed = FALSE; private $defaultTimeLimit = 0; private $stopOnDefect = FALSE; private $registerMockObjectsFromTestArgumentsRecursively = FALSE }) Standard input code:424                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
   ├ PHP   4. PHPUnit\Framework\TestResult->run($test = class PKP\tests\jobs\notifications\NewAnnouncementNotifyUsersTest { protected $backupGlobals = TRUE; protected $backupGlobalsExcludeList = []; protected $backupGlobalsBlacklist = []; protected $backupStaticAttributes = NULL; protected $backupStaticAttributesExcludeList = []; protected $backupStaticAttributesBlacklist = []; protected $runTestInSeparateProcess = NULL; protected $preserveGlobalState = TRUE; protected $providedTests = [0 => class PHPUnit\Framework\ExecutionOrderDependency { ... }]; private ${PHPUnit\Framework\TestCase}runClassInSeparateProcess = NULL; private ${PHPUnit\Framework\TestCase}inIsolation = TRUE; private ${PHPUnit\Framework\TestCase}data = []; private ${PHPUnit\Framework\TestCase}dataName = ''; private ${PHPUnit\Framework\TestCase}expectedException = NULL; private ${PHPUnit\Framework\TestCase}expectedExceptionMessage = NULL; private ${PHPUnit\Framework\TestCase}expectedExceptionMessageRegExp = NULL; private ${PHPUnit\Framework\TestCase}expectedExceptionCode = NULL; private ${PHPUnit\Framework\TestCase}name = 'testRunSerializedJob'; private ${PHPUnit\Framework\TestCase}dependencies = []; private ${PHPUnit\Framework\TestCase}dependencyInput = []; private ${PHPUnit\Framework\TestCase}iniSettings = []; private ${PHPUnit\Framework\TestCase}locale = []; private ${PHPUnit\Framework\TestCase}mockObjects = []; private ${PHPUnit\Framework\TestCase}mockObjectGenerator = NULL; private ${PHPUnit\Framework\TestCase}status = -1; private ${PHPUnit\Framework\TestCase}statusMessage = ''; private ${PHPUnit\Framework\TestCase}numAssertions = 0; private ${PHPUnit\Framework\TestCase}result = class PHPUnit\Framework\TestResult { private $passed = [...]; private $passedTestClasses = [...]; private $currentTestSuiteFailed = FALSE; private $errors = [...]; private $failures = [...]; private $warnings = [...]; private $notImplemented = [...]; private $risky = [...]; private $skipped = [...]; private $listeners = [...]; private $runTests = 1; private $time = 0; private $codeCoverage = NULL; private $convertDeprecationsToExceptions = FALSE; private $convertErrorsToExceptions = TRUE; private $convertNoticesToExceptions = TRUE; private $convertWarningsToExceptions = TRUE; private $stop = FALSE; private $stopOnError = FALSE; private $stopOnFailure = FALSE; private $stopOnWarning = FALSE; private $beStrictAboutTestsThatDoNotTestAnything = TRUE; private $beStrictAboutOutputDuringTests = TRUE; private $beStrictAboutTodoAnnotatedTests = FALSE; private $beStrictAboutResourceUsageDuringSmallTests = FALSE; private $enforceTimeLimit = FALSE; private $forceCoversAnnotation = FALSE; private $timeoutForSmallTests = 1; private $timeoutForMediumTests = 10; private $timeoutForLargeTests = 60; private $stopOnRisky = FALSE; private $stopOnIncomplete = FALSE; private $stopOnSkipped = FALSE; private $lastTestFailed = FALSE; private $defaultTimeLimit = 0; private $stopOnDefect = FALSE; private $registerMockObjectsFromTestArgumentsRecursively = FALSE }; private ${PHPUnit\Framework\TestCase}testResult = NULL; private ${PHPUnit\Framework\TestCase}output = ''; private ${PHPUnit\Framework\TestCase}outputExpectedRegex = NULL; private ${PHPUnit\Framework\TestCase}outputExpectedString = NULL; private ${PHPUnit\Framework\TestCase}outputCallback = FALSE; private ${PHPUnit\Framework\TestCase}outputBufferingActive = TRUE; private ${PHPUnit\Framework\TestCase}outputBufferingLevel = 1; private ${PHPUnit\Framework\TestCase}outputRetrievedForAssertion = FALSE; private ${PHPUnit\Framework\TestCase}snapshot = NULL; private ${PHPUnit\Framework\TestCase}prophet = NULL; private ${PHPUnit\Framework\TestCase}beStrictAboutChangesToGlobalState = FALSE; private ${PHPUnit\Framework\TestCase}registerMockObjectsFromTestArgumentsRecursively = FALSE; private ${PHPUnit\Framework\TestCase}warnings = []; private ${PHPUnit\Framework\TestCase}groups = []; private ${PHPUnit\Framework\TestCase}doesNotPerformAssertions = FALSE; private ${PHPUnit\Framework\TestCase}customComparators = []; private ${PHPUnit\Framework\TestCase}doubledTypes = []; private array ${PKP\tests\PKPTestCase}daoBackup = []; private array ${PKP\tests\PKPTestCase}registryBackup = ['request' => NULL]; private array ${PKP\tests\PKPTestCase}containerBackup = []; private array ${PKP\tests\PKPTestCase}mockedRegistryKeys = [0 => 'request']; protected string $serializedJobData = 'O:49:"PKP\\jobs\\notifications\\NewAnnouncementNotifyUsers":7:{s:15:"\000*\000recipientIds";O:29:"Illuminate\\Support\\Collection":2:{s:8:"\000*\000items";a:3:{i:0;i:2;i:1;i:3;i:2;i:4;}s:28:"\000*\000escapeWhenCastingToString";b:0;}s:12:"\000*\000contextId";i:1;s:17:"\000*\000announcementId";i:1;s:9:"\000*\000locale";s:2:"en";s:9:"\000*\000sender";O:13:"PKP\\user\\User":7:{s:5:"_data";a:22:{s:2:"id";i:1;s:8:"userName";s:5:"admin";s:8:"password";s:60:"$2y$10$uFmYXg8/Ufa0HbskyW57Be22stFGY5qtxJZmTOae3PfDB86V3x7BW";s:5:"email";s:23:"pkpadmin@mailinator.com";s'... }) /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestCase.php:964
   ├ PHP   5. PHPUnit\Framework\TestCase->runBare() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestResult.php:728                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
   ├ PHP   6. PHPUnit\Framework\TestCase->runTest() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestCase.php:1214                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
   ├ PHP   7. PKP\tests\jobs\notifications\NewAnnouncementNotifyUsersTest->testRunSerializedJob() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/lib/vendor/phpunit/phpunit/src/Framework/TestCase.php:1608                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
   ├ PHP   8. PKP\jobs\notifications\NewAnnouncementNotifyUsers->handle() /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/tests/jobs/notifications/NewAnnouncementNotifyUsersTest.php:125                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
   ├ PHP   9. PKP\mail\mailables\AnnouncementNotify->setData($locale = 'en') /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/jobs/notifications/NewAnnouncementNotifyUsers.php:91                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
   ├ PHP  10. PKP\mail\Mailable->setData($locale = 'en') /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/classes/mail/mailables/AnnouncementNotify.php:74                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
   ├ PHP  11. APP\mail\variables\ContextEmailVariable->values($locale = 'en') /home/asmecher/git/ojs-stable-3_4_0/lib/pkp/classes/mail/Mailable.php:234                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
   ├ PHP  12. htmlspecialchars($string = NULL) /home/asmecher/git/ojs-stable-3_4_0/classes/mail/variables/ContextEmailVariable.php:49                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  1. The StatisticsReportMail job seems to hang after the following output:
Statistics Report Mail (PKP\tests\jobs\notifications\StatisticsReportMail)
 ✔ Unserialization get proper job instance  4 ms

@asmecher I have resolved the PHPUnit deprecations warnings But unable to reproduce the issue when running the test StatisticsReportMail to be halted. In my case it's all running fine . Is there any error stack after the job test halted ?

touhidurabir commented 1 week ago

@asmecher I have updated the tests to backup and restore mocked DAO and container keys but unable to reproduce the issue that happening in your machine as we had seen in our last test . And it seems that it was happening for https://github.com/pkp/jatsTemplate/blob/main/tests/functional/ArticleBodyTest.php which only present in the main branch but not in the stable-3.4.0 branch . in fact for https://github.com/pkp/jatsTemplate in stable-3.4.0 , there is no tests at all . Any idea what I am missing .

I was able to complete all tests (not only jobs test) for stable-3.4.0 branch for OJS, OMP and OPS without any issue .