Browse Source

Bug 16155: Adjust a few other tests

Accounts.t: Only added a line that ensures the MPL branch exists.
AnonymiseIssueHistory.t: Only add a branch to work with.
Barcodes.t: Replaced clear with delete_all.
CalcFine.t: Remove default issuing rule and add one instead of updating.
Holds.t: Add category S in case it would not exist.
Members.t: Replaced clear with delete_all.
MoveItemFromBiblio.t: Replace last _fk construction.

Test plan:
Run these tests. (See note).
Git grep for only_fk, {_fk} and TestBuilder::default_value.

Note: Holds.t does not pass. Tests 9 and 39 fail, but they did already.
not ok 9 - GetReservesFromItemnumber should return a valid borrowernumber
not ok 39 - Test AlterPriority(), move to bottom
So this test needs attention, but on another report please :)

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
16.05.x
Marcel de Rooy 7 years ago
committed by Kyle M Hall
parent
commit
2862b19918
  1. 7
      t/db_dependent/Accounts.t
  2. 8
      t/db_dependent/Barcodes.t
  3. 11
      t/db_dependent/Circulation/AnonymiseIssueHistory.t
  4. 7
      t/db_dependent/Circulation/CalcFine.t
  5. 6
      t/db_dependent/Holds.t
  6. 11
      t/db_dependent/Items/MoveItemFromBiblio.t
  7. 3
      t/db_dependent/Members.t

7
t/db_dependent/Accounts.t

@ -52,11 +52,10 @@ my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
# this test needs a MPL branch; also create another one
my $builder = t::lib::TestBuilder->new();
my $library = $builder->build({
source => 'Branch',
});
$builder->build({ source => 'Branch', value => { branchcode => 'MPL' }});
my $library = $builder->build({ source => 'Branch' });
$dbh->do(q|DELETE FROM accountlines|);
$dbh->do(q|DELETE FROM issues|);

8
t/db_dependent/Barcodes.t

@ -43,8 +43,8 @@ subtest 'Test generation of annual barcodes from DB values' => sub {
plan tests => 4;
$builder->clear( { source => 'Issue' } );
$builder->clear( { source => 'Item' } );
$builder->schema->resultset( 'Issue' )->delete_all;
$builder->schema->resultset( 'Item' )->delete_all;
my $barcodeobj;
@ -84,8 +84,8 @@ subtest 'Test generation of annual barcodes from DB values' => sub {
};
$builder->clear( { source => 'Issue' } );
$builder->clear( { source => 'Item' } );
$builder->schema->resultset( 'Issue' )->delete_all;
$builder->schema->resultset( 'Item' )->delete_all;
my %thash = (
incremental => [],

11
t/db_dependent/Circulation/AnonymiseIssueHistory.t

@ -35,14 +35,19 @@ $schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
# TODO create a subroutine in t::lib::Mocks
my $userenv_patron = $builder->build( { source => 'Borrower', }, );
my $branch = $builder->build({ source => 'Branch' });
my $userenv_patron = $builder->build({
source => 'Borrower',
value => { branchcode => $branch->{branchcode} },
});
C4::Context->_new_userenv('DUMMY SESSION');
C4::Context->set_userenv(
$userenv_patron->{borrowernumber},
$userenv_patron->{userid},
'usercnum', 'First name', 'Surname',
$userenv_patron->{_fk}{branchcode}{branchcode},
$userenv_patron->{_fk}{branchcode}{branchname}, 0
$branch->{branchcode},
$branch->{branchname},
0,
);
my $anonymous = $builder->build( { source => 'Borrower', }, );

7
t/db_dependent/Circulation/CalcFine.t

@ -65,6 +65,13 @@ my $item = $builder->build(
subtest 'Test basic functionality' => sub {
plan tests => 1;
my $rule = $builder->schema->resultset('Issuingrule')->find({
branchcode => '*',
categorycode => '*',
itemtype => '*',
});
$rule->delete if $rule;
my $issuingrule = $builder->build(
{
source => 'Issuingrule',

6
t/db_dependent/Holds.t

@ -34,6 +34,12 @@ my $dbh = C4::Context->dbh;
my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode };
# This test assumes we have a category S. This statement helps.
$builder->build({
source => 'Category',
value => { categorycode => 'S', category_type => 'S' },
});
my $borrowers_count = 5;
$dbh->do('DELETE FROM itemtypes');

11
t/db_dependent/Items/MoveItemFromBiblio.t

@ -23,14 +23,21 @@ use C4::Reserves;
use Koha::Database;
use t::lib::TestBuilder;
use Data::Dumper qw|Dumper|;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
# NOTE This is a trick, if we want to populate the biblioitems table, we should not create a Biblio but a Biblioitem
my $from_biblio = $builder->build( { source => 'Biblioitem', } )->{_fk}{biblionumber};
my $to_biblio = $builder->build( { source => 'Biblioitem', } )->{_fk}{biblionumber};
my $param = { source => 'Biblioitem' };
my $from_biblio = {
biblionumber => $builder->build($param)->{biblionumber},
};
my $to_biblio = {
biblionumber => $builder->build($param)->{biblionumber},
};
my $item1 = $builder->build(
{ source => 'Item',
value => { biblionumber => $from_biblio->{biblionumber}, },

3
t/db_dependent/Members.t

@ -262,7 +262,6 @@ $builder->build({
},
});
#$builder->clear( { source => 'Borrower' } );
my $borrower1 = $builder->build({
source => 'Borrower',
value => {
@ -343,7 +342,7 @@ $patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id
is( scalar(@$patstodel),1,'Borrower with issue not deleted by category_code and list');
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } );
is( scalar(@$patstodel),1,'Borrower with issue not deleted by expiration_date and list');
$builder->clear( { source => 'Issue' } );
$builder->schema->resultset( 'Issue' )->delete_all;
$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} );
ok( scalar(@$patstodel)== 2,'Borrowers without issue deleted from list');
$patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } );

Loading…
Cancel
Save