Bug 24448: Unit tests
This patch adds tests for the new method to be introduced. It also moves the tests for Koha::Biblio->subscriptions to the Biblio.t where it really belongs. To test, run this tests along with the patch implementing the new method. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.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
4111f4f186
commit
81c93cac46
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 11;
|
||||
use Test::More tests => 12;
|
||||
|
||||
use C4::Biblio;
|
||||
use Koha::Database;
|
||||
|
|
@ -541,3 +541,38 @@ subtest 'orders() and active_orders_count() tests' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'subscriptions() and subscriptions_count() tests' => sub {
|
||||
|
||||
plan tests => 6;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $biblio = $builder->build_sample_biblio;
|
||||
|
||||
my $subscriptions = $biblio->subscriptions;
|
||||
is( ref($subscriptions), 'Koha::Subscriptions',
|
||||
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
|
||||
);
|
||||
is( $subscriptions->count, 0, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
|
||||
is( $biblio->subscriptions_count, 0, 'subscriptions_count returns the correct number' );
|
||||
|
||||
# Add two subscriptions
|
||||
foreach (1..2) {
|
||||
$builder->build_object(
|
||||
{
|
||||
class => 'Koha::Subscriptions',
|
||||
value => { biblionumber => $biblio->biblionumber }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$subscriptions = $biblio->subscriptions;
|
||||
is( ref($subscriptions), 'Koha::Subscriptions',
|
||||
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
|
||||
);
|
||||
is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
|
||||
is( $biblio->subscriptions_count, 2, 'subscriptions_count returns the correct number' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 6;
|
||||
use Test::More tests => 5;
|
||||
use Test::Exception;
|
||||
use MARC::Field;
|
||||
|
||||
|
|
@ -81,22 +81,6 @@ subtest 'holds + current_holds' => sub {
|
|||
|
||||
};
|
||||
|
||||
subtest 'subscriptions' => sub {
|
||||
plan tests => 2;
|
||||
$builder->build(
|
||||
{ source => 'Subscription', value => { biblionumber => $biblio->id } }
|
||||
);
|
||||
$builder->build(
|
||||
{ source => 'Subscription', value => { biblionumber => $biblio->id } }
|
||||
);
|
||||
my $biblio = Koha::Biblios->find( $biblio->id );
|
||||
my $subscriptions = $biblio->subscriptions;
|
||||
is( ref($subscriptions), 'Koha::Subscriptions',
|
||||
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
|
||||
);
|
||||
is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
|
||||
};
|
||||
|
||||
subtest 'waiting_or_in_transit' => sub {
|
||||
plan tests => 4;
|
||||
my $biblio = $builder->build( { source => 'Biblio' } );
|
||||
|
|
|
|||
Loading…
Reference in New Issue