Once #3504039: Consolidate contrib module setup is done, we should know if any of the current tests are failing. If they are, fix them.
Additionally, as part of #3504036: Document features please determine if any features are missing substantial test coverage and document what's missing here.
Non-obvious Fixes
Please check my proposals/assumptions.
- In
GiftAidRelatedContextsSubscriberI removed the test against a draft order because for sure the order is draft during the checkout process when looking for an existing declaration. - Charity has accessor methods for some fields that no longer exist so I removed them. The alternative of course would be to put the fields back.
- Currently I have disabled the code in
Declaration::postSave()for "If this declaration has had its end date edited, force the same end date on other ongoing declarations for the same context." Firstly the consequences were baffling me for many hours and I probably won't be alone😃. Secondly it seems unnecessary as the separate declarations will do the right thing anyway. Thirdly I am unsure about the legal compliance: it seems better to report to HMRC the declaration exactly as they were made. If someone chooses to extend a declaration we should do what they ask; if they choose to make a new declaration we should also do what they ask. Fourthly (obviously fixable) it seems bugged: a declaration for 2023 plus one for 2025 would wrongly also cover 2024. Finally consider the case that a declaration is added by mistake, then shortly after removed - it could have corrupted many other declarations. I disabled the corresponding test. - I simplified the code in
DeclarationStorage::getActiveByAnyContext()so it just returns the most recently declared, and removed the corresponding tests. It seems that it shouldn't really matter which one we return if multiple are relevant, and I couldn't conceive of any rule relating to start/end dates that actually works reliably.
Questions/problems
Please let me know what you prefer, or we can discuss.
- The routes
gift_aid.declaration_makeandgift_aid.declaration_extendare apparently missing the corresponding form. I'm not sure if they are still needed - potentially we could reuse the add and edit forms?? - DeclarationFormTest has code that expects special button text changes and thank-you messages, however I can't see corresponding code to generate them. Either I can change the tests or add code to match.
- I'm not sure that the calculated field
Declaration:statusis going to work. The value depends on the date, so it would break any caching. Also I'm not sure we need it: the functiongetStatus()is fine for most purposes. I believe we can rewrite the various functions inDeclarationStorageto work without it - and at the same time be faster, and take an extra parameter of a timestamp. This seems important as we can't always assume the current date is the correct perspective: for example suppose someone adds an order in the past or edits the date or an order. (This one isn't breaking any tests - it's just something I spotted.)
Issue fork gift_aid-3504041
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
adamps commentedComment #4
adamps commentedI pushed a first commit without a MR, because the MR system didn't seem to be available.
However it seems to be available now, likely because the version field is now set. So if my first commit wasn't enough then I should be able to create a MR for the next step.
Comment #8
adamps commentedComment #9
adamps commentedYou set me some interesting challenges to guess how you intended the code to be😃. I'm getting close to the limit now of what I can do until you can clarify/resolve some uncertainties please.
Comment #10
adamps commentedIn https://git.drupalcode.org/project/gift_aid/-/jobs/4280333
Comment #11
jonathanshawNice work! And challenging :)
I'm fine to leave commited the changes you've made, but some need further discussion in new more specific issues, ideally with the removed code in the IS for consideration, or a link to the commit in the MR here.
New issue. Your point is valid, but I'm not sure a past declaration on a draft order should be considered to have been truly declared.
New issue please. Your points are good, but I had a good reason we should consider how to address.
New issue. That code looks ok to me.
Let's remove extend, I can't see an important case for extending a declaration rather than just making a new one.
For make, please open a new issue.
I think this is what I was working on when I stalled 2 years ago. I suggest opening a new issue, and give some consideration to what the form should be like. Hopefully it's just changing it to match the tests, but might be more complex. Happy for you to also do simple changes here to get the tests passing if you prefer.
New issue. We could appropriate cache expiry to the entity. I guess the purpose of it was for display (a computed field being more elegant than hook_entity_extra_field), but I'm open to other approaches to displaying status.
New issue. Sounds like a good idea.
Undefined array key "wrapper_element"That's an annotation on a commerce checkout pane plugin.
Comment #12
jonathanshawNew issue please. I'm not sure what's right here, that might get clearer. I suspect we need to display the charity number and address to users at some point.
Comment #13
jonathanshawComment #14
adamps commentedYes I considered that, but there is a default value in the pane manager so it should be fine. Eventually I discovered that
PaneVisibilityTest::getPane()creates the pane without calling the manager, so it ignores the annotation.😃Comment #15
adamps commentedHurrah, tests are green. I'm ready to commit, so please do any more review if you wish.
I raised:
Comment #16
jonathanshawNice, thanks Adam.
Comment #17
adamps commentedComment #19
adamps commentedThanks I will continue in #3505391: Fix problems arising from "Consolidate tests"
Comment #20
adamps commentedComment #21
adamps commentedAlso I raised #3505467: Finish the declaration forms
Comment #22
adamps commentedAmusingly and rather confusingly, the tests fail in the morning and pass in the afternoon😃. Fix coming up soon.
Comment #25
adamps commentedComment #26
adamps commented