{ amount => -5 , days_ago => $days , description =>'purge_zero_balance_fees should not delete fees with negative amout owed on threshold day' , delete => 0 } ,
{ amount => -5 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day' , delete => 0 }
);
-
-my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => 'PT', branchcode => $branchcode } )->store();
+my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
+my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => $categorycode, branchcode => $branchcode } )->store();
for my $data ( @test_data ) {
$sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
use Test::More tests => 12;
+use t::lib::TestBuilder;
+
use_ok('C4::Acquisition');
use_ok('C4::Biblio');
use_ok('C4::Budgets');
# Start transaction
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
+my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
+my $curcode = $builder->build({ source => 'Currency' })->{currencycode};
+
my $bookseller = Koha::Acquisition::Bookseller->new(
{
name => "my vendor",
biblionumber => $subscription->{biblionumber},
entrydate => '01-01-2013',
quantity => 1,
- currency => 'USD',
+ currency => $curcode,
listprice => $cost,
notes => "This is a note",
basketno => $basketno,
my $bookseller = $builder->build( { source => 'Aqbookseller' } );
my $budget = $builder->build( { source => 'Aqbudget' } );
my $staffmember = $builder->build( { source => 'Borrower' } );
+my $curcode = $builder->build( { source => 'Currency' })->{currencycode};
# Create baskets and orders
basketno => $basketno,
biblionumber => $biblionumber,
budget_id => $budget->{budget_id},
- currency => 'USD',
+ currency => $curcode,
quantity => 0,
rrp => 42,
rrp_tax_included => 42,
use POSIX qw(strftime);
use Test::More tests => 49;
-use Koha::Database;
+use t::lib::TestBuilder;
+
+use Koha::Database;
use Koha::Biblio;
use Koha::Patron;
use Koha::Library;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
+my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
)->insert();
ok( $biblioitem->id, 'biblioitem created' );
+my $itype = $builder->build({ source => 'Itemtype' });
my $item = Koha::Item->new(
{
biblionumber => $biblio->id,
biblioitemnumber => $biblioitem->id,
- itype => $schema->resultset('Itemtype')->search()->next()->itemtype(),
+ itype => $itype->{itype},
}
)->store();
ok( $item->id, 'Koha::Item created' );
-my $branch = Koha::Libraries->search()->next();
-my $category = $schema->resultset('Category')->next();
+my $branch = $builder->build({ source => 'Branch' });
+my $category = $builder->build({ source => 'Category' });
my $patron = Koha::Patron->new(
{
- categorycode => $category->id,
- branchcode => $branch->id,
+ categorycode => $category->{categorycode},
+ branchcode => $branch->{branchcode},
}
)->store();
ok( $patron->id, 'Koha::Patron created' );
use Modern::Perl;
use Test::More tests => 15;
+use t::lib::TestBuilder;
+
+use Koha::Database;
use C4::Context;
use Koha::AuthorisedValue;
use Koha::AuthorisedValues;
use Koha::AuthorisedValueCategories;
use Koha::MarcSubfieldStructures;
-my $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+my $builder = t::lib::TestBuilder->new;
-$dbh->do("DELETE FROM authorised_values");
-$dbh->do("DELETE FROM authorised_value_categories");
+Koha::AuthorisedValues->delete;
+Koha::AuthorisedValueCategories->delete;
# insert
Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store;
Koha::AuthorisedValues->new()->search( { category => 'av_for_testing' } );
is( @authorised_values, 3, "Get correct number of values" );
-my $branches_rs = Koha::Database->new()->schema()->resultset('Branch')->search();
-my $branch1 = $branches_rs->next();
-my $branchcode1 = $branch1->branchcode();
-my $branch2 = $branches_rs->next();
-my $branchcode2 = $branch2->branchcode();
+my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
+my $branchcode2 = $builder->build({ source => 'Branch' })->{branchcode};
$av1->add_branch_limitation( $branchcode1 );
);
};
};
+
+$schema->storage->txn_rollback;
use MARC::Record;
use t::lib::Mocks;
+use t::lib::TestBuilder;
use Koha::Database;
+use Koha::Authority::Types;
BEGIN {
use_ok('C4::AuthoritiesMarc');
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
+my $builder = t::lib::TestBuilder->new;
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
+# Authority type GEOGR_NAME is hardcoded here
+if( ! Koha::Authority::Types->find('GEOGR_NAME') ) {
+ $builder->build({ source => 'AuthType', value => { authtypecode => 'GEOGR_NAME' }});
+};
+
is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
my $expectedhierarchy = [ [ {
use Test::MockModule;
use Test::Warn;
+use t::lib::TestBuilder;
+
use C4::Context;
use Koha::DateUtils;
use DateTime::Duration;
my $database = Koha::Database->new();
my $schema = $database->schema();
$schema->storage->txn_begin();
-
$dbh->{RaiseError} = 1;
+my $builder = t::lib::TestBuilder->new;
#Start tests
$dbh->do(q|DELETE FROM aqorders|);
$dbh->do(q|DELETE FROM aqbooksellers|);
$dbh->do(q|DELETE FROM subscription|);
+# Add currency
+my $curcode = $builder->build({ source => 'Currency' })->{currencycode};
+
#Test AddBookseller
my $count = Koha::Acquisition::Booksellers->search()->count();
my $sample_supplier1 = {
biblionumber => $biblionumber,
budget_id => $id_budget,
entrydate => '01-01-2013',
- currency => 'EUR',
+ currency => $curcode,
notes => "This is a note1",
tax_rate => 0.0500,
orderstatus => 1,
biblionumber => $biblionumber,
budget_id => $id_budget,
entrydate => '01-01-2013',
- currency => 'EUR',
+ currency => $curcode,
notes => "This is a note2",
tax_rate => 0.0500,
orderstatus => 1,
biblionumber => $biblionumber,
budget_id => $id_budget,
entrydate => '02-02-2013',
- currency => 'EUR',
+ currency => $curcode,
notes => "This is a note3",
tax_rate => 0.0500,
orderstatus => 2,
biblionumber => $biblionumber,
budget_id => $id_budget,
entrydate => '02-02-2013',
- currency => 'EUR',
+ currency => $curcode,
notes => "This is a note3",
tax_rate => 0.0500,
orderstatus => 2,
# It requires a working Koha database with the sample data
use Modern::Perl;
+use DateTime::Format::MySQL;
+use Test::More tests => 7;
+
+use t::lib::TestBuilder;
+
use C4::Context;
+use Koha::Database;
use Koha::DateUtils qw(dt_from_string);
use Koha::AuthorisedValue;
use Koha::AuthorisedValueCategories;
-use Test::More tests => 7;
-use DateTime::Format::MySQL;
-
BEGIN {
use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesCategorized));
use_ok('C4::Members');
}
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
+
+our $itype_1 = $builder->build({ source => 'Itemtype' });
subtest 'Authorized Values Tests' => sub {
plan tests => 3;
};
subtest 'Itemtype info Tests' => sub {
- like ( getitemtypeinfo('BK')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
- like ( getitemtypeinfo('BK', 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
- like ( getitemtypeinfo('BK', 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
+ like ( getitemtypeinfo( $itype_1->{itemtype} )->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
+ like ( getitemtypeinfo( $itype_1->{itemtype}, 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
+ like ( getitemtypeinfo( $itype_1->{itemtype}, 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
};
### test for C4::Koha->GetDailyQuote()
is_deeply(\@results,\@expected, 'GetItemTypesCategorized: grouped and ungrouped items returned as expected.');
};
-$dbh->rollback();
+$schema->storage->txn_rollback;
use Modern::Perl;
use Test::More tests => 57;
use t::lib::Mocks qw(mock_preference);
+use t::lib::TestBuilder;
use POSIX qw(strftime);
use Data::Dumper;
use Koha::Biblios;
_count )
);
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
$dbh->do('DELETE FROM issues');
$dbh->do('DELETE FROM biblio');
my $cardnumber1 = 'test_card1';
my $cardnumber2 = 'test_card2';
my $cardnumber3 = 'test_card3';
- my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode();
- my $branchcode = Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
+ my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
+ my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
my $query = '
INSERT INTO borrowers
}
}
-$dbh->rollback;
+$schema->storage->txn_rollback;