my $builder = t::lib::TestBuilder->new;
my $library = $builder->build( { source => 'Branch' } );
-$dbh->do(q|DELETE FROM accountlines|);
-$dbh->do(q|DELETE FROM issues|);
-$dbh->do(q|DELETE FROM borrowers|);
-
my $branchcode = $library->{branchcode};
my $context = Test::MockModule->new('C4::Context');
plan tests => 8;
- Koha::Account::Lines->delete();
- Koha::Patrons->delete();
Koha::Notice::Messages->delete();
- # Create a borrower
- my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
- my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
-
- my $borrower = Koha::Patron->new(
- {
- cardnumber => 'chelseahall',
- surname => 'Hall',
- firstname => 'Chelsea',
- email => 'chelsea@example.com',
- categorycode => $categorycode,
- branchcode => $branchcode,
- }
- )->store();
+ # Create a patron
+ my $patron = $builder->build_object({ class => 'Koha::Patrons' });
my $manager = $builder->build_object({ class => "Koha::Patrons" });
my $context = Test::MockModule->new('C4::Context');
branch => $manager->branchcode,
};
});
- my $account = Koha::Account->new({ patron_id => $borrower->id });
+ my $account = Koha::Account->new({ patron_id => $patron->borrowernumber });
my $line = Koha::Account::Line->new(
{
- borrowernumber => $borrower->borrowernumber,
+ borrowernumber => $patron->borrowernumber,
amountoutstanding => 27,
interface => 'commandline',
debit_type_code => 'LOST'
};
subtest 'pickup_locations' => sub {
- plan tests => 29;
+ plan tests => 8;
$schema->storage->txn_begin;
- my $dbh = C4::Context->dbh;
-
- # Cleanup database
- Koha::Holds->search->delete;
- Koha::Patrons->search->delete;
- Koha::Items->search->delete;
- Koha::Libraries->search->delete;
+ my $nb_libraries = Koha::Libraries->count;
Koha::CirculationRules->search->delete;
- $dbh->do('DELETE FROM issues');
Koha::CirculationRules->set_rules(
{
categorycode => undef,
my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
+ our @branchcodes = map { $_->branchcode } ($library1, $library2, $library3, $library4, $library5, $library6, $library7, $library8);
+
Koha::CirculationRules->set_rules(
{
branchcode => $library1->branchcode,
my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } );
my $results = {
- "ItemHomeLibrary-1-1" => 6,
+ "ItemHomeLibrary-1-1" => 6 + $nb_libraries,
"ItemHomeLibrary-1-8" => 1,
"ItemHomeLibrary-2-1" => 2,
"ItemHomeLibrary-2-8" => 0,
- "PatronLibrary-1-1" => 6,
+ "PatronLibrary-1-1" => 6 + $nb_libraries,
"PatronLibrary-1-8" => 3,
"PatronLibrary-2-1" => 0,
"PatronLibrary-2-8" => 3,
my @pl = $biblio->pickup_locations( { patron => $patron } );
foreach my $pickup_location (@pl) {
+ next
+ unless grep { $pickup_location eq $_ } @branchcodes;
+
is( ref($pickup_location), 'Koha::Library', 'Object type is correct' );
}
$schema->storage->txn_begin;
# Delete existing patrons
+ t::lib::Mocks::mock_preference('AnonymousPatron', '');
Koha::Checkouts->delete;
Koha::Patrons->delete;
# Create 10 patrons
use Modern::Perl;
-use Test::More tests => 5;
+use Test::More tests => 4;
use t::lib::Mocks;
use t::lib::TestBuilder;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
-# Delete all categories
-Koha::Checkouts->search->delete;
-Koha::Patrons->search->delete;
-Koha::Patron::Categories->search->delete;
-
my $builder = t::lib::TestBuilder->new;
-is( Koha::Template::Plugin::Categories->new->all->count,
- 0, '->all returns 0 results if no categories defined' );
+my $nb_categories = Koha::Patron::Categories->count;
# Create sample categories
my $category_1 = $builder->build( { source => 'Category' } );
my @categories = Koha::Template::Plugin::Categories->new->all;
-is( scalar(@categories), 1, '->all returns all defined categories' );
+is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' );
my $category_2 = $builder->build( { source => 'Category' } );
@categories = Koha::Template::Plugin::Categories->new->all;
-is( scalar(@categories), 2, '->all returns all defined categories' );
+is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' );
is( Koha::Template::Plugin::Categories->GetName(
$category_1->{categorycode}