View | Details | Raw Unified | Return to bug 14778
Collapse All | Expand All

(-)a/t/db_dependent/Borrower.t (-8 / +6 lines)
Lines 28-40 BEGIN { Link Here
28
    use_ok('Koha::Borrower');
28
    use_ok('Koha::Borrower');
29
}
29
}
30
30
31
# Start transaction
31
my $schema = Koha::Database->new->schema;
32
my $dbh = C4::Context->dbh;
32
$schema->storage->txn_begin;
33
$dbh->{AutoCommit} = 0;
34
$dbh->{RaiseError} = 1;
35
33
36
my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode();
34
my $categorycode = $schema->resultset('Category')->first()->categorycode();
37
my $branchcode = Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
35
my $branchcode = $schema->resultset('Branch')->first()->branchcode();
38
36
39
my $object = Koha::Borrower->new();
37
my $object = Koha::Borrower->new();
40
38
Lines 49-55 is( $object->in_storage, 1, "Object is now stored" ); Link Here
49
47
50
my $borrowernumber = $object->borrowernumber;
48
my $borrowernumber = $object->borrowernumber;
51
49
52
my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
50
my $borrower = $schema->resultset('Borrower')->find( $borrowernumber );
53
is( $borrower->surname(), "Test Surname", "Object found in database" );
51
is( $borrower->surname(), "Test Surname", "Object found in database" );
54
52
55
is( $object->is_changed(), 0, "Object is unchanged" );
53
is( $object->is_changed(), 0, "Object is unchanged" );
Lines 67-73 $object->store(); Link Here
67
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
65
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
68
66
69
$object->delete();
67
$object->delete();
70
$borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
68
$borrower = $schema->resultset('Borrower')->find( $borrowernumber );
71
ok( ! $borrower, "Object no longer found in database" );
69
ok( ! $borrower, "Object no longer found in database" );
72
is( $object->in_storage, 0, "Object is not in storage" );
70
is( $object->in_storage, 0, "Object is not in storage" );
73
71
(-)a/t/db_dependent/Items.t (-26 / +14 lines)
Lines 34-40 BEGIN { Link Here
34
    use_ok('Koha::Items');
34
    use_ok('Koha::Items');
35
}
35
}
36
36
37
my $dbh = C4::Context->dbh;
37
my $schema = Koha::Database->new->schema;
38
38
my $branches = GetBranches;
39
my $branches = GetBranches;
39
my ($branch1, $branch2) = keys %$branches;
40
my ($branch1, $branch2) = keys %$branches;
40
my $location = 'My Location';
41
my $location = 'My Location';
Lines 43-51 subtest 'General Add, Get and Del tests' => sub { Link Here
43
44
44
    plan tests => 14;
45
    plan tests => 14;
45
46
46
    # Start transaction
47
    $schema->storage->txn_begin;
47
    $dbh->{AutoCommit} = 0;
48
    $dbh->{RaiseError} = 1;
49
48
50
    # Create a biblio instance for testing
49
    # Create a biblio instance for testing
51
    C4::Context->set_preference('marcflavour', 'MARC21');
50
    C4::Context->set_preference('marcflavour', 'MARC21');
Lines 88-94 subtest 'General Add, Get and Del tests' => sub { Link Here
88
    is( $getitem->{location}, 'CART', "The location should have been set to CART" );
87
    is( $getitem->{location}, 'CART', "The location should have been set to CART" );
89
    is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" );
88
    is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" );
90
89
91
    $dbh->rollback;
90
    $schema->storage->txn_rollback;
92
};
91
};
93
92
94
subtest 'GetHiddenItemnumbers tests' => sub {
93
subtest 'GetHiddenItemnumbers tests' => sub {
Lines 97-105 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
97
96
98
    # This sub is controlled by the OpacHiddenItems system preference.
97
    # This sub is controlled by the OpacHiddenItems system preference.
99
98
100
    # Start transaction
99
    $schema->storage->txn_begin;
101
    $dbh->{AutoCommit} = 0;
102
    $dbh->{RaiseError} = 1;
103
100
104
    # Create a new biblio
101
    # Create a new biblio
105
    C4::Context->set_preference('marcflavour', 'MARC21');
102
    C4::Context->set_preference('marcflavour', 'MARC21');
Lines 175-190 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
175
    @hidden = GetHiddenItemnumbers( @items );
172
    @hidden = GetHiddenItemnumbers( @items );
176
    ok( scalar @hidden == 0, "Empty items list, no item hidden");
173
    ok( scalar @hidden == 0, "Empty items list, no item hidden");
177
174
178
    $dbh->rollback;
175
    $schema->storage->txn_rollback;
179
};
176
};
180
177
181
subtest 'GetItemsInfo tests' => sub {
178
subtest 'GetItemsInfo tests' => sub {
182
179
183
    plan tests => 4;
180
    plan tests => 4;
184
181
185
    # Start transaction
182
    $schema->storage->txn_begin;
186
    $dbh->{AutoCommit} = 0;
187
    $dbh->{RaiseError} = 1;
188
183
189
    # Add a biblio
184
    # Add a biblio
190
    my ($biblionumber, $biblioitemnumber) = get_biblio();
185
    my ($biblionumber, $biblioitemnumber) = get_biblio();
Lines 212-227 subtest 'GetItemsInfo tests' => sub { Link Here
212
    is( exists( $results[0]->{ onsite_checkout } ), 1,
207
    is( exists( $results[0]->{ onsite_checkout } ), 1,
213
        'GetItemsInfo returns a onsite_checkout key' );
208
        'GetItemsInfo returns a onsite_checkout key' );
214
209
215
    $dbh->rollback;
210
    $schema->storage->txn_rollback;
216
};
211
};
217
212
218
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
213
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
219
214
220
    plan tests => 4;
215
    plan tests => 4;
221
216
222
    # Start transaction
217
    $schema->storage->txn_begin;
223
    $dbh->{AutoCommit} = 0;
224
    $dbh->{RaiseError} = 1;
225
218
226
    my $schema = Koha::Database->new()->schema();
219
    my $schema = Koha::Database->new()->schema();
227
220
Lines 260-274 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { Link Here
260
                $effective_itemtype eq 'BIB_LEVEL',
253
                $effective_itemtype eq 'BIB_LEVEL',
261
        '$item->effective_itemtype() falls back to biblioitems.itemtype when item-level_itypes is enabled but undef' );
254
        '$item->effective_itemtype() falls back to biblioitems.itemtype when item-level_itypes is enabled but undef' );
262
255
263
    $dbh->rollback;
256
    $schema->storage->txn_rollback;
264
};
257
};
265
258
266
subtest 'SearchItems test' => sub {
259
subtest 'SearchItems test' => sub {
267
    plan tests => 14;
260
    plan tests => 14;
268
261
269
    # Start transaction
262
    $schema->storage->txn_begin;
270
    $dbh->{AutoCommit} = 0;
263
    my $dbh = C4::Context->dbh;
271
    $dbh->{RaiseError} = 1;
272
264
273
    C4::Context->set_preference('marcflavour', 'MARC21');
265
    C4::Context->set_preference('marcflavour', 'MARC21');
274
    my $cpl_items_before = SearchItemsByField( 'homebranch', 'CPL');
266
    my $cpl_items_before = SearchItemsByField( 'homebranch', 'CPL');
Lines 424-440 subtest 'SearchItems test' => sub { Link Here
424
    my $cpl_items_after = SearchItemsByField( 'homebranch', 'CPL');
416
    my $cpl_items_after = SearchItemsByField( 'homebranch', 'CPL');
425
    is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItemsByField should return something' );
417
    is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItemsByField should return something' );
426
418
427
    $dbh->rollback;
419
    $schema->storage->txn_rollback;
428
};
420
};
429
421
430
subtest 'Koha::Item(s) tests' => sub {
422
subtest 'Koha::Item(s) tests' => sub {
431
423
432
    plan tests => 5;
424
    plan tests => 5;
433
425
434
    # Start transaction
435
    my $schema = Koha::Database->new()->schema();
436
    $schema->storage->txn_begin();
426
    $schema->storage->txn_begin();
437
    $dbh->{RaiseError} = 1;
438
427
439
    # Create a biblio and item for testing
428
    # Create a biblio and item for testing
440
    C4::Context->set_preference('marcflavour', 'MARC21');
429
    C4::Context->set_preference('marcflavour', 'MARC21');
Lines 457-464 subtest 'Koha::Item(s) tests' => sub { Link Here
457
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
446
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
458
    plan tests => 7;
447
    plan tests => 7;
459
448
460
    $dbh->{AutoCommit} = 0;
449
    $schema->storage->txn_begin();
461
    $dbh->{RaiseError} = 1;
462
450
463
    my ( $biblionumber, $biblioitemnumber ) = get_biblio();
451
    my ( $biblionumber, $biblioitemnumber ) = get_biblio();
464
    my $item_infos = [
452
    my $item_infos = [
(-)a/t/db_dependent/Reports_Guided.t (-8 / +5 lines)
Lines 21-26 use Test::More tests => 18; Link Here
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use C4::Context;
23
use C4::Context;
24
use Koha::Database;
24
25
25
BEGIN {
26
BEGIN {
26
    use_ok('C4::Reports::Guided');
27
    use_ok('C4::Reports::Guided');
Lines 30-40 can_ok( Link Here
30
    qw(save_report delete_report execute_query)
31
    qw(save_report delete_report execute_query)
31
);
32
);
32
33
33
#Start transaction
34
my $schema = Koha::Database->new->schema;
34
my $dbh = C4::Context->dbh;
35
$schema->storage->txn_begin;
35
$dbh->{RaiseError} = 1;
36
$dbh->{AutoCommit} = 0;
37
36
37
my $dbh = C4::Context->dbh;
38
$dbh->do(q|DELETE FROM saved_sql|);
38
$dbh->do(q|DELETE FROM saved_sql|);
39
$dbh->do(q|DELETE FROM saved_reports|);
39
$dbh->do(q|DELETE FROM saved_reports|);
40
40
Lines 118-123 ok( Link Here
118
is_deeply( get_report_areas(), [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ],
118
is_deeply( get_report_areas(), [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ],
119
    "get_report_areas returns the correct array of report areas");
119
    "get_report_areas returns the correct array of report areas");
120
120
121
#End transaction
121
$schema->storage->txn_rollback;
122
$dbh->rollback;
123
124
- 

Return to bug 14778