Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 36; |
20 |
use Test::More tests => 37; |
21 |
use Test::Exception; |
21 |
use Test::Exception; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 1549-1554
subtest 'opac_summary_html' => sub {
Link Here
|
1549 |
); |
1549 |
); |
1550 |
}; |
1550 |
}; |
1551 |
|
1551 |
|
|
|
1552 |
subtest 'can_be_edited() tests' => sub { |
1553 |
|
1554 |
plan tests => 6; |
1555 |
|
1556 |
$schema->storage->txn_begin; |
1557 |
|
1558 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } ); |
1559 |
my $biblio = $builder->build_sample_biblio; |
1560 |
|
1561 |
my $source_allows_editing = 1; |
1562 |
|
1563 |
my $mock_metadata = Test::MockModule->new('Koha::Biblio::Metadata'); |
1564 |
$mock_metadata->mock( 'source_allows_editing', sub { return $source_allows_editing; } ); |
1565 |
|
1566 |
ok( !$biblio->can_be_edited($patron), "Patron needs 'edit_catalog' subpermission" ); |
1567 |
|
1568 |
# Add editcatalogue => edit_catalog subpermission |
1569 |
$builder->build( |
1570 |
{ |
1571 |
source => 'UserPermission', |
1572 |
value => { |
1573 |
borrowernumber => $patron->id, |
1574 |
module_bit => 9, # editcatalogue |
1575 |
code => 'edit_catalogue', |
1576 |
}, |
1577 |
} |
1578 |
); |
1579 |
|
1580 |
ok( $biblio->can_be_edited($patron), "Patron with 'edit_catalogue' can edit" ); |
1581 |
|
1582 |
# Mock the record source doesn't allow direct editing |
1583 |
$source_allows_editing = 0; |
1584 |
ok( !$biblio->can_be_edited($patron), "Patron needs 'edit_locked_record' subpermission for locked records" ); |
1585 |
|
1586 |
# Add editcatalogue => edit_catalog subpermission |
1587 |
$builder->build( |
1588 |
{ |
1589 |
source => 'UserPermission', |
1590 |
value => { |
1591 |
borrowernumber => $patron->id, |
1592 |
module_bit => 9, # editcatalogue |
1593 |
code => 'edit_locked_records', |
1594 |
}, |
1595 |
} |
1596 |
); |
1597 |
ok( $biblio->can_be_edited($patron), "Patron needs 'edit_locked_record' subpermission for locked records" ); |
1598 |
|
1599 |
throws_ok { $biblio->can_be_edited() } |
1600 |
'Koha::Exceptions::MissingParameter', |
1601 |
'Exception thrown on missing parameter'; |
1602 |
|
1603 |
my $potato = 'Potato'; |
1604 |
|
1605 |
throws_ok { $biblio->can_be_edited($potato) } |
1606 |
'Koha::Exceptions::MissingParameter', |
1607 |
'Exception thrown if parameter not a Koha::Patron reference'; |
1608 |
|
1609 |
$schema->storage->txn_rollback; |
1610 |
}; |
1611 |
|
1552 |
sub component_record1 { |
1612 |
sub component_record1 { |
1553 |
my $marc = MARC::Record->new; |
1613 |
my $marc = MARC::Record->new; |
1554 |
$marc->append_fields( |
1614 |
$marc->append_fields( |
1555 |
- |
|
|