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

(-)a/t/db_dependent/Items/AutomaticItemModificationByAge.t (-9 / +24 lines)
Lines 13-21 use C4::Items; Link Here
13
use Koha::DateUtils;
13
use Koha::DateUtils;
14
use t::lib::TestBuilder;
14
use t::lib::TestBuilder;
15
15
16
my $schema = Koha::Database->new->schema;
17
$schema->storage->txn_begin;
16
my $dbh = C4::Context->dbh;
18
my $dbh = C4::Context->dbh;
17
$dbh->{AutoCommit} = 0;
18
$dbh->{RaiseError} = 1;
19
19
20
my $builder = t::lib::TestBuilder->new;
20
my $builder = t::lib::TestBuilder->new;
21
21
Lines 23-38 my $builder = t::lib::TestBuilder->new; Link Here
23
my $library = $builder->build( { source => 'Branch' })->{branchcode};
23
my $library = $builder->build( { source => 'Branch' })->{branchcode};
24
my $library2 = $builder->build( { source => 'Branch' })->{branchcode};
24
my $library2 = $builder->build( { source => 'Branch' })->{branchcode};
25
25
26
my $frameworkcode = ''; # FIXME We do not want to insert the whole mapping, but we should use another frameworkcode
26
$dbh->do(q|
27
$dbh->do(q|
27
    DELETE FROM marc_subfield_structure
28
    DELETE FROM marc_subfield_structure
28
    WHERE kohafield = 'items.new_status' OR kohafield = 'items.stocknumber'
29
    WHERE ( kohafield = 'items.new_status' OR kohafield = 'items.stocknumber' )
29
|);
30
    AND frameworkcode = ?
31
|, undef, $frameworkcode);
30
32
31
my $new_tagfield = 'i';
33
my $new_tagfield = 'i';
32
$dbh->do(qq|
34
$dbh->do(qq|
33
    INSERT INTO marc_subfield_structure(tagfield, tagsubfield, kohafield, frameworkcode)
35
    INSERT INTO marc_subfield_structure(tagfield, tagsubfield, kohafield, frameworkcode)
34
    VALUES ( 952, '$new_tagfield', 'items.new_status', '' )
36
    VALUES ( 952, ?, 'items.new_status', ? )
35
|);
37
|, undef, $new_tagfield, $frameworkcode);
38
39
# Clear cache
40
my $cache = Koha::Caches->get_instance();
41
$cache->clear_from_cache("MarcStructure-0-$frameworkcode");
42
$cache->clear_from_cache("MarcStructure-1-$frameworkcode");
43
$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
44
$cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
36
45
37
my $record = MARC::Record->new();
46
my $record = MARC::Record->new();
38
$record->append_fields(
47
$record->append_fields(
Lines 40-46 $record->append_fields( Link Here
40
    MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
49
    MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
41
    MARC::Field->new('942', ' ', ' ', c => 'ITEMTYPE_T'),
50
    MARC::Field->new('942', ' ', ' ', c => 'ITEMTYPE_T'),
42
);
51
);
43
my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, '');
52
my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, $frameworkcode);
44
53
45
my ($item_bibnum, $item_bibitemnum, $itemnumber) = C4::Items::AddItem(
54
my ($item_bibnum, $item_bibitemnum, $itemnumber) = C4::Items::AddItem(
46
    {
55
    {
Lines 55-61 my ($item_bibnum, $item_bibitemnum, $itemnumber) = C4::Items::AddItem( Link Here
55
my $item = C4::Items::GetItem( $itemnumber );
64
my $item = C4::Items::GetItem( $itemnumber );
56
is ( $item->{new_status}, 'new_value', q|AddItem insert the 'new_status' field| );
65
is ( $item->{new_status}, 'new_value', q|AddItem insert the 'new_status' field| );
57
66
58
my ( $tagfield, undef ) = GetMarcFromKohaField('items.itemnumber', '');
67
my ( $tagfield, undef ) = GetMarcFromKohaField('items.itemnumber', $frameworkcode);
59
my $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber );
68
my $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber );
60
is( $marc_item->subfield($tagfield, $new_tagfield), 'new_value', q|Koha mapping is correct|);
69
is( $marc_item->subfield($tagfield, $new_tagfield), 'new_value', q|Koha mapping is correct|);
61
70
Lines 288-290 C4::Items::ToggleNewStatus( { rules => \@rules } ); Link Here
288
297
289
$modified_item = C4::Items::GetItem( $itemnumber );
298
$modified_item = C4::Items::GetItem( $itemnumber );
290
is( $modified_item->{new_status}, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|);
299
is( $modified_item->{new_status}, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|);
291
- 
300
301
# Clear cache
302
my $cache = Koha::Caches->get_instance();
303
$cache->clear_from_cache("MarcStructure-0-$frameworkcode");
304
$cache->clear_from_cache("MarcStructure-1-$frameworkcode");
305
$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
306
$cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");

Return to bug 18761