Bug 24464: Unit tests
Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
7f815b258f
commit
f85d85f380
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 6;
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
||||
|
|
@ -109,6 +109,36 @@ subtest 'basket_group' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'creator() tests' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $basket = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Acquisition::Baskets',
|
||||
value => { authorisedby => undef }
|
||||
}
|
||||
);
|
||||
|
||||
is( $basket->creator, undef, 'Undef is handled as expected' );
|
||||
|
||||
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
$basket->authorisedby( $patron->borrowernumber )->store->discard_changes;
|
||||
|
||||
my $creator = $basket->creator;
|
||||
is( ref($creator), 'Koha::Patron', 'Return type is correct' );
|
||||
is( $creator->borrowernumber, $patron->borrowernumber, 'Returned object is the right one' );
|
||||
|
||||
# Delete the patron
|
||||
$patron->delete;
|
||||
|
||||
is( $basket->creator, undef, 'Undef is handled as expected' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'to_api() tests' => sub {
|
||||
|
||||
plan tests => 6;
|
||||
|
|
|
|||
Loading…
Reference in New Issue