WriteOffFee )
);
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $builder = t::lib::TestBuilder->new();
-my $schema = Koha::Database->new()->schema();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError}=1;
#!/usr/bin/perl
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, see <http://www.gnu.org/licenses>.
+
use Modern::Perl;
+
use Test::More tests => 7;
use Test::MockModule;
use t::lib::TestBuilder;
+use Koha::Database;
+
BEGIN {
use_ok('C4::Barcodes::ValueBuilder');
};
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $builder = t::lib::TestBuilder->new;
+
my $dbh = C4::Context->dbh;
$dbh->do(q|DELETE FROM items|);
my $item_1 = $builder->build({
($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args);
is($nextnum, '2012-0035', 'annual barcode');
is($scr, undef, 'annual javascript');
+
+$schema->storage->txn_rollback;
+
+1;
-#!/usr/bin/perl;
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 17;
use t::lib::TestBuilder;
use Koha::Borrower::Discharge;
+use Koha::Database;
+
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
+
my $dbh = C4::Context->dbh;
$dbh->do(q|DELETE FROM discharges|);
# The error is:
# DBIx::Class::ResultSet::create(): DBI Exception: DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction [for Statement "INSERT INTO discharges ( borrower, needed, validated) VALUES ( ?, ?, ? )" with ParamValues: 0='121', 1='2014-01-08T16:38:29', 2=undef] at /home/koha/src/Koha/DataObject/Discharge.pm line 33
#is( Koha::Service::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} }), 1, 'Discharge request sent' );
+
+$schema->storage->txn_rollback;
+
+1;
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
+
use t::lib::TestBuilder;
use Test::More tests => 3;
+use Koha::Database;
+
BEGIN {
use_ok('C4::Category');
}
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $builder = t::lib::TestBuilder->new();
+
my $nonexistent_categorycode = 'NONEXISTEN';
$builder->build({
source => 'Category',
my $match = grep {$_->{categorycode} eq $nonexistent_categorycode } @categories;
is( $match, 1, 'all returns the inserted category');
+
+$schema->storage->txn_rollback;
+
+1;
+
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
use Modern::Perl;
+
use Test::More tests => 3;
use C4::Context;
use C4::Circulation;
+use Koha::Database;
+
use t::lib::Mocks;
use t::lib::TestBuilder;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $builder = t::lib::TestBuilder->new;
# TODO create a subroutine in t::lib::Mocks
|, undef, $item->{itemnumber});
is( $borrowernumber_used_to_anonymised, undef, 'With AnonymousPatron is not defined, the issue should have been anonymised anyway' );
};
+
+$schema->storage->txn_rollback;
+
+1;
#!/usr/bin/perl
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, see <http://www.gnu.org/licenses>.
+
use Modern::Perl;
use Test::More tests => 6;
use C4::Context;
use C4::Context;
use Koha::DateUtils qw( dt_from_string );
+use Koha::Database;
use t::lib::TestBuilder;
use t::lib::Mocks;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
our $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM items|);
teardown();
};
+$schema->storage->txn_rollback;
+
sub teardown {
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM issuingrules|);
}
+
+1;
use Test::More tests => 2;
use C4::Members;
use Koha::DateUtils;
+use Koha::Database;
+
use t::lib::TestBuilder;
use t::lib::Mocks qw( mock_preference );
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $builder = t::lib::TestBuilder->new();
+
+$ENV{ DEBUG } = 0;
+
subtest 'Tests for CanBookBeIssued related to dateexpiry' => sub {
plan tests => 4;
can_book_be_issued();
my $t2 = time;
is( ref $d eq "DateTime" && $t2 - $t1 < 1, 1, "CalcDateDue with expiry in year 9876 in " . sprintf( "%6.4f", $t2 - $t1 ) . " seconds." );
}
+
+$schema->storage->txn_rollback;
+
+1;
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
use Modern::Perl;
+
use Test::More tests => 3;
+use t::lib::TestBuilder;
+
use MARC::Record;
use MARC::File::USMARC;
-use MARC::File::XML;# ( BinaryEncoding => 'utf-8' );
-#use XML::Simple;
+use MARC::File::XML;
use MARC::Batch;
-use t::lib::TestBuilder;
use File::Slurp;
-#use utf8;
use Encode;
use C4::Biblio;
use C4::Context;
-
+use Koha::Database;
use Koha::Exporter::Record;
-my $dbh = C4::Context->dbh;
-#$dbh->{AutoCommit} = 0;
-#$dbh->{RaiseError} = 1;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
-#$dbh->do(q|DELETE FROM issues|);
-#$dbh->do(q|DELETE FROM reserves|);
-#$dbh->do(q|DELETE FROM items|);
-#$dbh->do(q|DELETE FROM biblio|);
-#$dbh->do(q|DELETE FROM auth_header|);
+my $dbh = C4::Context->dbh;
my $biblio_1_title = 'Silence in the library';
-#my $biblio_2_title = Encode::encode('UTF-8', 'The art of computer programming ກ ຂ ຄ ງ ຈ ຊ ຍ é');
my $biblio_2_title = 'The art of computer programming ກ ຂ ຄ ງ ຈ ຊ ຍ é';
my $biblio_1 = MARC::Record->new();
$biblio_1->leader('00266nam a22001097a 4500');
$title = Encode::encode('UTF-8', $title);
is( $title, $biblio_2_title, 'Export ISO2709: The title is correctly encoded' );
};
+
+$schema->storage->txn_rollback;
+
+1;
use C4::Items;
use C4::Members;
use C4::Calendar;
-
-use Koha::Holds;
-
+use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
+use Koha::Holds;
BEGIN {
use FindBin;
use_ok('C4::Reserves');
}
-my $builder = t::lib::TestBuilder->new();
-my $dbh = C4::Context->dbh;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
-# Start transaction
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
+my $builder = t::lib::TestBuilder->new();
+my $dbh = C4::Context->dbh;
# Create two random branches
my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
use C4::Context;
use C4::Branch;
+use Koha::Database;
use Koha::DateUtils;
use DateTime;
use_ok('C4::Calendar');
}
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $dbh = C4::Context->dbh();
-# Start transaction
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new();
# Create two fresh branches for the tests
is( Koha::Calendar->new( branchcode => $branch_2 )->is_holiday( $today ), 1, "Today is a holiday for $branch_2" );
is( Koha::Calendar->new( branchcode => $branch_1 )->is_holiday( $today ), 0, "Today is not a holiday for $branch_1");
-$dbh->rollback;
+$schema->storage->txn_rollback;
1;
use_ok('Koha::Items');
}
-my $schema = Koha::Database->new->schema;
+my $schema = Koha::Database->new->schema;
my $branches = GetBranches;
my ($branch1, $branch2) = keys %$branches;
$schema->storage->txn_begin;
- my $schema = Koha::Database->new()->schema();
-
my $biblio =
$schema->resultset('Biblio')->create(
{
use C4::Items;
use C4::Reserves;
+use Koha::Database;
use t::lib::TestBuilder;
+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
is( $get_bib_level_hold->{biblionumber}, $from_biblio->{biblionumber}, 'MoveItemFromBiblio should not have moved the biblio-level hold' );
is( $get_item_level_hold_1->{biblionumber}, $from_biblio->{biblionumber}, 'MoveItemFromBiblio should not have moved the item-level hold placed on item 1' );
is( $get_item_level_hold_2->{biblionumber}, $to_biblio->{biblionumber}, 'MoveItemFromBiblio should have moved the item-level hold placed on item 2' );
+
+$schema->storage->txn_rollback;
+
+1;
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
+
use Test::More tests => 4;
+
use Koha::City;
use Koha::Cities;
+use Koha::Database;
+
use t::lib::TestBuilder;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $builder = t::lib::TestBuilder->new;
my $nb_of_cities = Koha::Cities->search->count;
my $new_city_1 = Koha::City->new({
$retrieved_city_1->delete;
is( Koha::Cities->search->count, $nb_of_cities + 1, 'Delete should have deleted the city' );
+
+$schema->storage->txn_rollback;
+
+1;
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-use C4::Members;
+
+use Test::More tests => 5;
use Test::MockModule;
use t::lib::TestBuilder;
use t::lib::Mocks qw( mock_preference );
-use Test::More tests => 5;
-use Test::MockModule;
+use C4::Members;
+use Koha::Database;
BEGIN {
use_ok('C4::Members');
}
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
my $date_time = new Test::MockModule('DateTime');
$date_time->mock(
'now', sub {
$upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
is(scalar(@$upcoming_mem_expires), 0, 'Get upcoming membership expires without MembershipExpiryDaysNotice should return 0.');
+
+$schema->storage->txn_rollback;
+
+1;
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
+
use Test::More tests => 5;
use Test::MockModule;
+use t::lib::TestBuilder;
use C4::Circulation;
use C4::Reserves qw|AddReserve|;
-use t::lib::TestBuilder;
+use Koha::Database;
+
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
my $mContext = new Test::MockModule('C4::Context');
$mContext->mock( 'userenv', sub {
is( $fee > 0, 1, 'Patron 2 should be charged again this time' );
# End of tests
-
sub acctlines { #calculate number of accountlines for a patron
my @temp = $dbh->selectrow_array( "SELECT COUNT(*) FROM accountlines WHERE borrowernumber=?", undef, ( $_[0] ) );
return $temp[0];
''
);
}
+
+$schema->storage->txn_rollback;
+
+1;