Bug 23152

Summary: koha_object[s]_class methods must be implemented when needed
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: enhancement    
Priority: P5 - low CC: martin.renvoize, nick
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00
Attachments: Bug 23152: Add tests
Bug 23152: Implement koha_object[s]_class when needed
Bug 23152: Add tests
Bug 23152: Implement koha_object[s]_class when needed
Bug 23152: Fix more pluralisation (and add tests)

Description Jonathan Druart 2019-06-19 02:41:53 UTC
We should implement koha_object_class and koha_objects_class for all our modules.

For instance we cannot do Koha::Hold->get_from_storage from tests, it will result in the following error: 

Can't locate object method "_new_from_dbic" via package "Koha::Reserve" (perhaps you forgot to load "Koha::Reserve"?) at /home/vagrant/kohaclone/Koha/Object.pm line 267.
Comment 1 Jonathan Druart 2019-06-19 02:43:45 UTC
Created attachment 90765 [details] [review]
Bug 23152: Add tests
Comment 2 Jonathan Druart 2019-06-19 02:43:49 UTC
Created attachment 90766 [details] [review]
Bug 23152: Implement koha_object[s]_class when needed

A simple use case is the ->get_from_storage (useful when writing tests)

Test plan:
Apply only the first patch and notice the test failures
Apply the second patch and confirm the the tests are returning green
Comment 3 Martin Renvoize 2019-06-19 16:06:56 UTC
Created attachment 90803 [details] [review]
Bug 23152: Add tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2019-06-19 16:06:59 UTC
Created attachment 90804 [details] [review]
Bug 23152: Implement koha_object[s]_class when needed

A simple use case is the ->get_from_storage (useful when writing tests)

Test plan:
Apply only the first patch and notice the test failures
Apply the second patch and confirm the the tests are returning green

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2019-06-19 16:08:49 UTC
This is a bit of a no-brainer and something I've been meaning to get around to doing myself for a while.

Going straight for PQA as the patch is trivial to read and the qa scripts don't complain.

The test currently fails, but the reason is clear and it just warrants an RM followup on push to bring it up to date with the available classes at the time of push.

Passing QA.
Comment 6 Jonathan Druart 2019-06-19 16:11:36 UTC
(In reply to Martin Renvoize from comment #5)
> This is a bit of a no-brainer

I wrote a script ;)
Comment 7 Martin Renvoize 2019-06-24 16:03:42 UTC
Nice work!

Pushed to master for 19.11.00
Comment 8 Martin Renvoize 2019-06-25 05:51:57 UTC
I missed that the tests here don't actually test the koha_objects_class at all here.. would be good to get a test for that method too.
Comment 9 Jonathan Druart 2019-06-25 22:26:49 UTC
Created attachment 91005 [details] [review]
Bug 23152: Fix more pluralisation (and add tests)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 10 Martin Renvoize 2019-10-24 16:02:39 UTC
Pushed the last follow-up.. oops.. i missed this one for ages :S