Lines 20-26
use Modern::Perl;
Link Here
|
20 |
use utf8; |
20 |
use utf8; |
21 |
use Encode; |
21 |
use Encode; |
22 |
|
22 |
|
23 |
use Test::More tests => 12; |
23 |
use Test::More tests => 13; |
24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
25 |
use Test::Mojo; |
25 |
use Test::Mojo; |
26 |
use Test::Warn; |
26 |
use Test::Warn; |
Lines 1724-1726
subtest 'add_item() tests' => sub {
Link Here
|
1724 |
|
1724 |
|
1725 |
$schema->storage->txn_rollback; |
1725 |
$schema->storage->txn_rollback; |
1726 |
}; |
1726 |
}; |
1727 |
- |
1727 |
|
|
|
1728 |
subtest 'update_item() tests' => sub { |
1729 |
plan tests => 7; |
1730 |
|
1731 |
$schema->storage->txn_begin; |
1732 |
|
1733 |
my $patron = $builder->build_object( |
1734 |
{ |
1735 |
class => 'Koha::Patrons', |
1736 |
value => { flags => 0 } |
1737 |
} |
1738 |
); |
1739 |
my $password = 'thePassword123'; |
1740 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
1741 |
my $userid = $patron->userid; |
1742 |
|
1743 |
my $item = $builder->build_sample_item({ replacementprice => 5 }); |
1744 |
my $biblio_id = $item->biblionumber; |
1745 |
my $item_id = $item->itemnumber; |
1746 |
|
1747 |
my $biblio = Koha::Biblios->find($item->biblionumber); |
1748 |
|
1749 |
my $matching_items = Koha::Items->search({ barcode => $item->barcode }); |
1750 |
|
1751 |
while (my $mbcitem = $matching_items->next) { |
1752 |
$mbcitem->delete if $mbcitem->biblionumber != $item->biblionumber; |
1753 |
} |
1754 |
|
1755 |
$t->put_ok("//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { external_id => 'something' }) |
1756 |
->status_is(403, 'Not enough permissions to update an item'); |
1757 |
|
1758 |
# Add permissions |
1759 |
$builder->build( |
1760 |
{ |
1761 |
source => 'UserPermission', |
1762 |
value => { |
1763 |
borrowernumber => $patron->borrowernumber, |
1764 |
module_bit => 9, |
1765 |
code => 'edit_catalogue' |
1766 |
} |
1767 |
} |
1768 |
); |
1769 |
|
1770 |
my $other_item = $builder->build_sample_item(); |
1771 |
|
1772 |
$t->put_ok("//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { |
1773 |
external_id => $other_item->barcode, |
1774 |
}) |
1775 |
->status_is(400, 'Barcode not unique'); |
1776 |
|
1777 |
$t->put_ok("//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { |
1778 |
replacement_price => 30, |
1779 |
}) |
1780 |
->status_is(200, 'Item updated') |
1781 |
->json_is('/replacement_price', 30); |
1782 |
|
1783 |
$schema->storage->txn_rollback; |
1784 |
}; |