User tests: Successful: Unsuccessful:
After #43879 and #43880 there are two System Tests are failing with Error: Unwanted PHP Deprecated
. This PR fix them and is:
The errors are displayed in the System Test after you have upgraded checkForPhpNoticesOrWarnings
to output. Verify the failed tests before patching. After patching, check if the test run was successful.
As preparation for the Cypress System Test install checkForPhpNoticesOrWarnings
with output in overwriting lines 74 ... 89 in node_modules/joomla-cypress/src/support.js
with the following lines:
Cypress.Commands.add('checkForPhpNoticesOrWarnings', () => {
cy.log('**Check for PHP notices and warnings**')
cy.document().then((doc) => {
const pageSource = doc.documentElement.innerHTML
// Search for PHP problem keywords in bold style with colon and collect the found keyword and the message
const regex = /<b>(Warning|Deprecated|Notice|Strict standards)<\/b>:(.*?)(<br|$)/
const match = regex.exec(pageSource)
if (match) {
// Directly fail with the reason, the keyword found and report the PHP problem message, e.g.
// Error: Unwanted PHP Warning: "Attempt to read property \"id\" on null in <b>/joomla-cms/components/com_newsfeeds/src/View/Category/HtmlView.php</b> on line <b>92</b>"
throw new Error(`Unwanted PHP ${match?.[1]}: ${JSON.stringify(match?.[2])}`)
}
})
cy.log('--Check for PHP notices and warnings--')
})
Run the two test specifications:
npx cypress run --spec tests/System/integration/site/components/com_content/Featured.cy.js,tests/System/integration/site/modules/mod_related_items/Default.cy.js
Fails with:
Running: components/com_content/Featured.cy.js (1 of 2)
Test in frontend that the content featured view
✓ can display an article (382ms)
✓ can not display not featured articles (116ms)
1) "after each" hook for "can navigate to the article"
2 passing (1s)
1 failing
1) Test in frontend that the content featured view
"after each" hook for "can navigate to the article":
Error: Unwanted PHP Deprecated: " DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in <b>/Users/hlu/Desktop/no_backup/joomla-cms/libraries/src/Date/Date.php</b> on line <b>126</b>"
...
Running: modules/mod_related_items/Default.cy.js (2 of 2)
Test in frontend that the related items module
1) "after each" hook for "can display a list of related articles based on the metakey field"
0 passing (874ms)
1 failing
1) Test in frontend that the related items module
"after each" hook for "can display a list of related articles based on the metakey field":
Error: Unwanted PHP Deprecated: " DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in <b>/Users/hlu/Desktop/no_backup/joomla-cms/libraries/src/Date/Date.php</b> on line <b>126</b>"
? With overwritten speaking checkForPhpNoticesOrWarnings
, if you run the entire system tests, there are four failures before this PR and only two after. #43879 and #43880 are fixing the other two.
? Do you running Cypress test in GUI mode and wonder where the deprecated errors are? They are hidden and you have to inspect the published date to see them in the HTML source code:
No deprecated errors in System Test with overwritten checkForPhpNoticesOrWarnings
.
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
@LadySolveig @bembelimen there is no up-merge required as it is only a down-merge from 5.1-dev
Status | New | ⇒ | Pending |
Category | ⇒ | JavaScript Unit Tests |
Labels |
Added:
Unit/System Tests
PR-4.4-dev
|
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-08-06 08:54:19 |
Closed_By | ⇒ | laoneo |
Thanks!
I have tested this item ✅ successfully on 9224986
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43881.