Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9899 Test for queue jobs #4285

Merged
merged 16 commits into from
Aug 12, 2024

Conversation

touhidurabir
Copy link
Member

No description provided.

Copy link
Member

@asmecher asmecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@touhidurabir, with apologies for the delays, I think base64-encoding everything is a cure worse than the disease -- it's impossible to understand the tests without passing the data through a base64 decoder. I'd suggest rather than e.g...

protected string $serializedJobData = 'Tzo0MjoiQVBQXGpvYnNcbm90aWZpY2F0aW9uc1xPcGVuQWNjZXNzTWFpbFVzZXJzIjo2OntzOjEwOiIAKgB1c2VySWRzIjtPOjI5OiJJbGx1bWluYXRlXFN1cHBvcnRcQ29sbGVjdGlvbiI6Mjp7czo4OiIAKgBpdGVtcyI7YToyOntpOjA7aToxO2k6MTtpOjI7fXM6Mjg6IgAqAGVzY2FwZVdoZW5DYXN0aW5nVG9TdHJpbmciO2I6MDt9czoxMjoiACoAY29udGV4dElkIjtpOjE7czoxMDoiACoAaXNzdWVJZCI7aToxO3M6MTA6ImNvbm5lY3Rpb24iO3M6ODoiZGF0YWJhc2UiO3M6NToicXVldWUiO3M6NToicXVldWUiO3M6NzoiYmF0Y2hJZCI7czozNjoiOWMxYzQ1MDItNTI2MS00YjRhLTk2NWMtMjU2Y2QwZWFhYWE0Ijt9';

...you could use...

protected string $serializedJobData = <<<END
O:42:"APP\\jobs\\notifications\\OpenAccessMailUsers":6:{s:10:"\0*\0userIds";O:29:"Illuminate\\Support\\Collection":2:{s:8:"\0*\0items";a:2:{i:0;i:1;i:1;i:2;}s:28:"\0*\0escapeWhenCastingToString";b:0;}s:12:"\0*\0contextId";i:1;s:10:"\0*\0issueId";i:1;s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";s:7:"batchId";s:36:"9c1c4502-5261-4b4a-965c-256cd0eaaaa4";}
END;

This is much more maintainable. I got the above by base64-decoding the contents, then escaping \ with \\ and null characters with \0.

@asmecher asmecher merged commit fbdf951 into pkp:stable-3_4_0 Aug 12, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants