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

(-)a/t/db_dependent/Koha/Patrons.t (-6 lines)
Lines 40-46 use t::lib::TestBuilder; Link Here
40
use t::lib::Mocks;
40
use t::lib::Mocks;
41
41
42
my $schema = Koha::Database->new->schema;
42
my $schema = Koha::Database->new->schema;
43
$schema->storage->txn_begin;
44
43
45
my $builder       = t::lib::TestBuilder->new;
44
my $builder       = t::lib::TestBuilder->new;
46
my $library = $builder->build({source => 'Branch' });
45
my $library = $builder->build({source => 'Branch' });
Lines 1425-1431 subtest 'Log cardnumber change' => sub { Link Here
1425
    is( scalar @logs, 2, 'With BorrowerLogs, Change in cardnumber should be logged, as well as general alert of patron mod.' );
1424
    is( scalar @logs, 2, 'With BorrowerLogs, Change in cardnumber should be logged, as well as general alert of patron mod.' );
1426
};
1425
};
1427
1426
1428
$schema->storage->txn_rollback;
1429
1427
1430
subtest 'Test Koha::Patrons::merge' => sub {
1428
subtest 'Test Koha::Patrons::merge' => sub {
1431
    plan tests => 110;
1429
    plan tests => 110;
Lines 1434-1440 subtest 'Test Koha::Patrons::merge' => sub { Link Here
1434
1432
1435
    my $resultsets = $Koha::Patron::RESULTSET_PATRON_ID_MAPPING;
1433
    my $resultsets = $Koha::Patron::RESULTSET_PATRON_ID_MAPPING;
1436
1434
1437
    $schema->storage->txn_begin;
1438
1435
1439
    my $keeper  = $builder->build_object({ class => 'Koha::Patrons' });
1436
    my $keeper  = $builder->build_object({ class => 'Koha::Patrons' });
1440
    my $loser_1 = $builder->build({ source => 'Borrower' })->{borrowernumber};
1437
    my $loser_1 = $builder->build({ source => 'Borrower' })->{borrowernumber};
Lines 1469-1481 subtest 'Test Koha::Patrons::merge' => sub { Link Here
1469
    is( Koha::Patrons->find($loser_1), undef, 'Loser 1 has been deleted' );
1466
    is( Koha::Patrons->find($loser_1), undef, 'Loser 1 has been deleted' );
1470
    is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' );
1467
    is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' );
1471
1468
1472
    $schema->storage->txn_rollback;
1473
};
1469
};
1474
1470
1475
subtest '->store' => sub {
1471
subtest '->store' => sub {
1476
    plan tests => 3;
1472
    plan tests => 3;
1477
    my $schema = Koha::Database->new->schema;
1473
    my $schema = Koha::Database->new->schema;
1478
    $schema->storage->txn_begin;
1479
1474
1480
    my $print_error = $schema->storage->dbh->{PrintError};
1475
    my $print_error = $schema->storage->dbh->{PrintError};
1481
    $schema->storage->dbh->{PrintError} = 0; ; # FIXME This does not longer work - because of the transaction in Koha::Patron->store?
1476
    $schema->storage->dbh->{PrintError} = 0; ; # FIXME This does not longer work - because of the transaction in Koha::Patron->store?
Lines 1497-1503 subtest '->store' => sub { Link Here
1497
    is( $patron_1->password, $digest, 'Password should not have changed on ->store');
1492
    is( $patron_1->password, $digest, 'Password should not have changed on ->store');
1498
1493
1499
    $schema->storage->dbh->{PrintError} = $print_error;
1494
    $schema->storage->dbh->{PrintError} = $print_error;
1500
    $schema->storage->txn_rollback;
1501
};
1495
};
1502
1496
1503
1497
(-)a/t/lib/TestBuilder.pm (-3 / +8 lines)
Lines 433-446 sub _gen_datetime { Link Here
433
sub _gen_text {
433
sub _gen_text {
434
    my ($self, $params) = @_;
434
    my ($self, $params) = @_;
435
    # From perldoc String::Random
435
    # From perldoc String::Random
436
    my $size = $params->{info}{size} // 10;
436
    my $size = $params->{info}{size} // 100;
437
    $size -= alt_rand(0.5 * $size);
437
    $size -= alt_rand(0.5 * $size);
438
    my $xss_data;
439
    if ( $size > 27 ) { #<script>alert('');</script>
440
        $xss_data = 1;
441
        $size -= 27;
442
    }
438
    my $regex = $size > 1
443
    my $regex = $size > 1
439
        ? '[A-Za-z][A-Za-z0-9_]{'.($size-1).'}'
444
        ? '[A-Za-z][A-Za-z0-9_]{'.($size-1).'}'
440
        : '[A-Za-z]';
445
        : '[A-Za-z]';
441
    my $random = String::Random->new( rand_gen => \&alt_rand );
446
    my $random = String::Random->new( rand_gen => \&alt_rand );
442
    # rand_gen is only supported from 0.27 onward
447
    # rand_gen is only supported from 0.27 onward
443
    return $random->randregex($regex);
448
    $random = $random->randregex($regex);
449
    return $xss_data ? qq|<script>alert('$random');</script>| : $random;
444
}
450
}
445
451
446
sub alt_rand { #Alternative randomizer
452
sub alt_rand { #Alternative randomizer
447
- 

Return to bug 13618