]> git.koha-community.org Git - koha.git/commit
Bug 25296: Make ->empty work for uninstantiated calls
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 29 Apr 2020 12:28:04 +0000 (09:28 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 29 Apr 2020 18:00:29 +0000 (19:00 +0100)
commit4805b9b9dd0a95d79faf450ed1aaaec62d544ec6
tree7d906d86668ffe6e00b7e4a8ab1d403cc61c7475
parent7acc0637093dbb569dc89d1a848114dc010997cd
Bug 25296: Make ->empty work for uninstantiated calls

In OO we would usually instantiate the class and then interact with it
like in:
    my $rs = Koha::Patrons->new;
    $rs->empty;

Koha's practice is to call things like Koha::Patrons->search without
instantiating the Koha::Patrons class. To keep consistency, this patch
instantiates the resultset object on behalf of the caller if required.

To test:
1. Apply the tests patch
2. Run:
   $ kshell
  $k prove t/db_dependent/Koha/Objects.t
=> FAIL: Tests fail because it is expected to have the class
instantiated
3. Apply this patch
4. Repeat 2.
=> SUCCESS: Tests pass, instantiation happens implicitly.
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Objects.pm