Summary: | itemnumber not available for plugin hook | ||
---|---|---|---|
Product: | Koha | Reporter: | Tomás Cohen Arazi (tcohen) <tomascohen> |
Component: | Architecture, internals, and plumbing | Assignee: | Tomás Cohen Arazi (tcohen) <tomascohen> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | major | ||
Priority: | P5 - low | CC: | jonathan.druart, kyle, lucas, martin.renvoize, nick, tomascohen |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27003 | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: |
20.11.00
|
|
Circulation function: | |||
Bug Depends on: | 22709, 23463 | ||
Bug Blocks: | |||
Attachments: |
Bug 26470: Regression tests
Bug 26470: Store the item before calling the after action hook Bug 26470: Regression tests Bug 26470: Store the item before calling the after action hook Bug 26470: Regression tests Bug 26470: Store the item before calling the after action hook |
Description
Tomás Cohen Arazi (tcohen)
2020-09-15 18:47:34 UTC
Created attachment 110119 [details] [review] Bug 26470: Regression tests This patch tweaks the test plugin so it composes an exception based on the fact that the hook was called with the item and item_id parameters defined. It then makes the tests expect a specific exception message with information about this. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t => FAIL: Tests fail! Created attachment 110120 [details] [review] Bug 26470: Store the item before calling the after action hook This patch makes Koha::Item->store call $self->SUPER::store before calling the hook, so things like the itemnumber (AUTO_INCREMENT field) are available to the plugin hook. It does so by storing the output on a temporary variable, to keep the current behaviour of just returning the output from SUPER::store. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t \ t/db_dependent/Koha/Item.t \ t/db_dependent/Koha/Items.t => FAIL: the hooks tests fail. Item.t hasn't been altered so should pass 3. Apply this patch 4. Repeat 2. => SUCCESS: Tests pass! Item.t as well! (i.e. no behaviour change) 5. Sign off :-D Created attachment 110134 [details] [review] Bug 26470: Regression tests This patch tweaks the test plugin so it composes an exception based on the fact that the hook was called with the item and item_id parameters defined. It then makes the tests expect a specific exception message with information about this. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t => FAIL: Tests fail! Signed-off-by: David Nind <david@davidnind.com> Created attachment 110135 [details] [review] Bug 26470: Store the item before calling the after action hook This patch makes Koha::Item->store call $self->SUPER::store before calling the hook, so things like the itemnumber (AUTO_INCREMENT field) are available to the plugin hook. It does so by storing the output on a temporary variable, to keep the current behaviour of just returning the output from SUPER::store. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t \ t/db_dependent/Koha/Item.t \ t/db_dependent/Koha/Items.t => FAIL: the hooks tests fail. Item.t hasn't been altered so should pass 3. Apply this patch 4. Repeat 2. => SUCCESS: Tests pass! Item.t as well! (i.e. no behaviour change) 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Created attachment 110185 [details] [review] Bug 26470: Regression tests This patch tweaks the test plugin so it composes an exception based on the fact that the hook was called with the item and item_id parameters defined. It then makes the tests expect a specific exception message with information about this. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t => FAIL: Tests fail! Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Created attachment 110186 [details] [review] Bug 26470: Store the item before calling the after action hook This patch makes Koha::Item->store call $self->SUPER::store before calling the hook, so things like the itemnumber (AUTO_INCREMENT field) are available to the plugin hook. It does so by storing the output on a temporary variable, to keep the current behaviour of just returning the output from SUPER::store. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t \ t/db_dependent/Koha/Item.t \ t/db_dependent/Koha/Items.t => FAIL: the hooks tests fail. Item.t hasn't been altered so should pass 3. Apply this patch 4. Repeat 2. => SUCCESS: Tests pass! Item.t as well! (i.e. no behaviour change) 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Trivial fix with included regression tests.. works as expected Passing QA Pushed to master for 20.11, thanks to everybody involved! doesn't apply clean to 20.05.x, no backport |