[Koha-devel] TestBuilder usage, recommendation

Tomas Cohen Arazi tomascohen at gmail.com
Mon Sep 11 18:19:56 CEST 2017


Hi everyone, on my QA-related tasks I've found many of us use TestBuilder
to generate random data for our tests (YAY!).
I just wanted to remind you that TestBuilder can now return
Koha::Object-derived objects instead of just unblessed hashes now, through
a new method:

my $builder = t::lib::TestBuilder->new();
my $patron = $builder->build_object({ class => 'Koha::Patrons' });

It was introduced to avoid this pattern we see very often on the tests:

my $builder = t::lib::TestBuilder->new();
my $patron_id = $builder->build({ source => 'Borrower'
})->{'borrowernumber'};
my $patron = Koha::Patrons->find( $patron_id );

(or just to make use of object accessors without all the symbols handling
hashrefs add, like in $patron->{'borrowernumber'}

At some point we could make ->build_object() replace ->build() for
simplicity.

Regards

-- 
Tomás Cohen Arazi
Theke Solutions (https://theke.io <http://theke.io/>)
✆ +54 9351 3513384
GPG: B2F3C15F
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20170911/81cf882a/attachment.html>


More information about the Koha-devel mailing list