|
Lines 89-98
subtest 'store' => sub {
Link Here
|
| 89 |
$biblio->biblioitem->itemtype, |
89 |
$biblio->biblioitem->itemtype, |
| 90 |
'items.itype must have been set to biblioitem.itemtype is not given' |
90 |
'items.itype must have been set to biblioitem.itemtype is not given' |
| 91 |
); |
91 |
); |
| 92 |
is( $item->permanent_location, $item->location, |
|
|
| 93 |
'permanent_location must have been set to location if not given' ); |
| 94 |
$item->delete; |
92 |
$item->delete; |
| 95 |
|
93 |
|
|
|
94 |
subtest 'permanent_location' => sub { |
| 95 |
plan tests => 7; |
| 96 |
|
| 97 |
my $location = 'my_loc'; |
| 98 |
my $attributes = { |
| 99 |
homebranch => $library->{branchcode}, |
| 100 |
holdingbranch => $library->{branchcode}, |
| 101 |
biblionumber => $biblio->biblionumber, |
| 102 |
location => $location, |
| 103 |
}; |
| 104 |
|
| 105 |
{ |
| 106 |
# NewItemsDefaultLocation not set |
| 107 |
t::lib::Mocks::mock_preference( 'NewItemsDefaultLocation', '' ); |
| 108 |
|
| 109 |
# Not passing permanent_location on creating the item |
| 110 |
my $item = Koha::Item->new($attributes)->store->get_from_storage; |
| 111 |
is( $item->location, $location, |
| 112 |
'location must have been set to location if given' ); |
| 113 |
is( $item->permanent_location, $item->location, |
| 114 |
'permanent_location must have been set to location if not given' ); |
| 115 |
$item->delete; |
| 116 |
|
| 117 |
# Passing permanent_location on creating the item |
| 118 |
$item = Koha::Item->new( |
| 119 |
{ %$attributes, permanent_location => 'perm_loc' } ) |
| 120 |
->store->get_from_storage; |
| 121 |
is( $item->permanent_location, 'perm_loc', |
| 122 |
'permanent_location must have been kept if given' ); |
| 123 |
$item->delete; |
| 124 |
} |
| 125 |
|
| 126 |
{ |
| 127 |
# NewItemsDefaultLocation set |
| 128 |
my $default_location = 'default_location'; |
| 129 |
t::lib::Mocks::mock_preference( 'NewItemsDefaultLocation', $default_location ); |
| 130 |
|
| 131 |
# Not passing permanent_location on creating the item |
| 132 |
my $item = Koha::Item->new($attributes)->store->get_from_storage; |
| 133 |
is( $item->location, $default_location, |
| 134 |
'location must have been set to default_location even if given' # FIXME this sounds wrong! Must be done in any cases? |
| 135 |
); |
| 136 |
is( $item->permanent_location, $location, |
| 137 |
'permanent_location must have been set to the location given' ); |
| 138 |
$item->delete; |
| 139 |
|
| 140 |
# Passing permanent_location on creating the item |
| 141 |
$item = Koha::Item->new( |
| 142 |
{ %$attributes, permanent_location => 'perm_loc' } ) |
| 143 |
->store->get_from_storage; |
| 144 |
is( $item->location, $default_location, |
| 145 |
'location must have been set to default_location even if given' # FIXME this sounds wrong! Must be done in any cases? |
| 146 |
); |
| 147 |
is( $item->permanent_location, $location, |
| 148 |
'permanent_location must have been set to the location given' |
| 149 |
); |
| 150 |
$item->delete; |
| 151 |
} |
| 152 |
|
| 153 |
}; |
| 154 |
|
| 96 |
subtest '*_on updates' => sub { |
155 |
subtest '*_on updates' => sub { |
| 97 |
plan tests => 9; |
156 |
plan tests => 9; |
| 98 |
|
157 |
|
| 99 |
- |
|
|