|
Lines 20-26
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 2; |
23 |
use Test::More tests => 3; |
| 24 |
|
24 |
|
| 25 |
use Koha::Database; |
25 |
use Koha::Database; |
| 26 |
use Koha::Suggestions; |
26 |
use Koha::Suggestions; |
|
Lines 49-51
subtest 'suggester() tests' => sub {
Link Here
|
| 49 |
|
49 |
|
| 50 |
$schema->storage->txn_rollback; |
50 |
$schema->storage->txn_rollback; |
| 51 |
}; |
51 |
}; |
| 52 |
- |
52 |
|
|
|
53 |
subtest 'strings_map() tests' => sub { |
| 54 |
plan tests => 2; |
| 55 |
|
| 56 |
$schema->txn_begin; |
| 57 |
|
| 58 |
my $av_value1 = Koha::AuthorisedValue->new( |
| 59 |
{ |
| 60 |
category => "SUGGEST_FORMAT", |
| 61 |
authorised_value => 'RECORD', |
| 62 |
lib => "Test format" |
| 63 |
} |
| 64 |
)->store; |
| 65 |
my $av_value2 = Koha::AuthorisedValue->new( |
| 66 |
{ |
| 67 |
category => "SUGGEST_STATUS", |
| 68 |
authorised_value => 'WANTED', |
| 69 |
lib => "Test status" |
| 70 |
} |
| 71 |
)->store; |
| 72 |
my $suggestion = $builder->build_object( |
| 73 |
{ class => 'Koha::Suggestions', value => { suggestedby => undef, STATUS => 'WANTED', itemtype => 'RECORD' } } ); |
| 74 |
|
| 75 |
my $strings_map = $suggestion->strings_map( { public => 0 } ); |
| 76 |
is_deeply( |
| 77 |
$strings_map, |
| 78 |
{ |
| 79 |
STATUS => { str => 'Test status', type => 'av', category => 'SUGGEST_STATUS' }, |
| 80 |
itemtype => { str => 'Test format', type => 'av', category => 'SUGGEST_FORMAT' }, |
| 81 |
patronreason => { str => $suggestion->patronreason, type => 'av', category => 'OPAC_SUG' }, |
| 82 |
}, |
| 83 |
'Strings map is correct' |
| 84 |
); |
| 85 |
|
| 86 |
my $av_value3 = Koha::AuthorisedValue->new( |
| 87 |
{ |
| 88 |
category => "OPAC_SUG", |
| 89 |
authorised_value => 'OPAC', |
| 90 |
lib => "An OPAC reason" |
| 91 |
} |
| 92 |
)->store; |
| 93 |
|
| 94 |
$suggestion->patronreason('OPAC'); |
| 95 |
$strings_map = $suggestion->strings_map( { public => 0 } ); |
| 96 |
is_deeply( |
| 97 |
$strings_map, |
| 98 |
{ |
| 99 |
STATUS => { str => 'Test status', type => 'av', category => 'SUGGEST_STATUS' }, |
| 100 |
itemtype => { str => 'Test format', type => 'av', category => 'SUGGEST_FORMAT' }, |
| 101 |
patronreason => { str => 'An OPAC reason', type => 'av', category => 'OPAC_SUG' }, |
| 102 |
}, |
| 103 |
'Strings map is correct' |
| 104 |
); |
| 105 |
|
| 106 |
$schema->txn_rollback; |
| 107 |
|
| 108 |
}; |