-
-
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
[NFC] Use insert ignore for inserts into civicrm_extension to stop warnings on duplicate entry for sequential credit notes extension #16644
[NFC] Use insert ignore for inserts into civicrm_extension to stop warnings on duplicate entry for sequential credit notes extension #16644
Conversation
(Standard links)
|
@seamuslee001 what about truncating the table between runs? We've done things very specific to this extension because it's the first but we don't see it being the only |
(presumably we would truncate in tearDown?) |
@eileenmcnaughton the table has been specifically excluded from the truncate https://github.com/civicrm/civicrm-core/blob/master/Civi/Test/Schema.php#L101 this i suspect is designed to help extension testing |
Hmm - well I'm OK merging this as it fixes but going forwards we probably need another way to check |
It works for me locally to fix it. I wonder if another way is to use |
@seamuslee001 ohh - I like @demeritcowboy's suggestion |
69d3551
to
14ce765
Compare
…rnings on duplicate entry for sequential credit notes extension
14ce765
to
27d7e15
Compare
updated it now @eileenmcnaughton @demeritcowboy |
Cool- next round we can get more generic |
Insert Ignore is different than Duplicate Update and will silently skip errors on real sites for the initial insert since this file isn't just for tests. I guess as long as it doesn't stay like this permanently? |
so @demeritcowboy if someone had actually disabled the extension we shouldn't be going through and updating the civicrm_extension row hence an insert ignore |
Ok I'm not following again but if you're good. |
I love the critical evaluation of the effect on real sites. In this case, I don't think it matters. Within the unit-testing world, I think I see/agree with @demeritcowboy's point about disabling. Suppose (hypothetically) you have complementary tests You would find that the tests were flaky/order-sensitive - because the Generally |
@totten at this stage the position is that core extensions are part of core & we only test with them enabled. We merged to docs to that effect https://docs.civicrm.org/dev/en/latest/extensions/ |
merging this - it solves the problem for now - this is an evolving area that we will hopefully make more generic as we move more code but for now this helps us get to the end of the beginning of the beginning |
Sure, if But extracting this functionality in an extension signals a long-term intention to allow the system to work with the toggle going either way (on or off), right? That was the purpose of extracting it to an extension? Eventually you'll want some amount of test-coverage for both situations (where the toggle is on and off) |
@totten the point of extracting stuff is more about making the code more readable & more modular. Yes it WILL work with sequentialcreditnotes off -(and yes I will disable it for my sites) but the problem with this &a bunch of other features are the way they are integrated into the code (hacks on the forms, spaghetti deep in the BAO) makes our code un-fixable. To look at the order api - it's not where it should be and that's largely because of add-on-features (this was one) embedded deeply into code that we need to make sensible in order to make it ready to support afform. |
"Eventually you'll want some amount of test-coverage for both situations (where the toggle is on and off)" - at the moment we have only figured out where to add coreextensions in to make them be tested & installed & added on upgrade - we need to make all of those things generic before that eventually happens so they all need to be revisited |
Overview
This resolved notices such as
occurring when running tests
Before
Notices show
After
No notices
Technical Details
The issue is that civicrm_extension table is not 'cleaned' out between test runs unlike other tables to ensure that we don't remove information on enabled extensions. This adds in some logic specific to the sequential credit notes extension as it is added via the civicrm_data.mysql file
ping @demeritcowboy @eileenmcnaughton @totten