-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Smarty - When temporarily setting variable, fix cleanup for previously-undefined values. #26465
Conversation
(Standard links)
|
@totten seems like test failure is related: CRM_Core_SmartyTest::testFetchWith_CleanNonExistent
Failed asserting that true is false.
/home/homer/buildkit/build/build-3/web/sites/all/modules/civicrm/tests/phpunit/CRM/Core/SmartyTest.php:36
/home/homer/buildkit/build/build-3/web/sites/all/modules/civicrm/tests/phpunit/CiviTest/CiviUnitTestCase.php:238
/home/homer/buildkit/extern/phpunit8/phpunit8.phar:1721 |
…orary assignments)
@monishdeb Yup, that was supposed to demonstrate the failure. I just pushed up the actual fix. Hopefully, fixing that doesn't cause massive trouble elsewhere... |
CRM_Core_Smarty_plugins_CrmScopeTest.testBlank with data set #2 "Undefined array key 'x'" I'm not clear why those haven't always failed. Possibly adding the useTransaction() stops the errors from getting swallowed somewhere. The fails are just a variation of all the warnings about smarty variables that never get assigned. So either, can't do those test cases, or the test would need updating to expect a php warning but do we really care to enforce that. Also case 9 is the same as case 2. Probably some history there, or maybe it was testing that you could repeat a test and still get the same result after all the other pushing and popping. |
Right, I'm pretty sure it was a leak between test-cases. Consider case
For all subsequent tests, they start with global (One way to confirm the interaction -- checkout the older code, then play around with disabling or reordering specific (This suggests that
Yeah, agree that doesn't need to be enforced. We could define the global/default value. Since
Oh, I like that explanation... :) |
Before: We rely on default/global value of `x=UNDEFINED` or `x=NULL`. But this is a bit tempermental. After: Clear default. Note: There's a prior commit which adds another test (CRM_Core_SmartyTest) where the global value is specifically undefined or specifically null. So that still has coverage.
Overview
You can temporarily assign Smarty values using various methods (
pushScope($vars)
/popScope()
orfetchWith(...$vars)
or{crmScope ...}
). This expands the test-coverage for that mechanism.Before
Fewer tests
After
Mo tests, mo problems.
Comments
Test expected to fail. Off-shoot from discussion with @demeritcowboy on #26432.
(Updated)
I've added a patch to fix the demonstrated failure.