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

(-)a/t/db_dependent/Letters/TemplateToolkit.t (-22 / +29 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 19;
22
use Test::More tests => 27;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 100-108 my $modification = $builder->build_object( Link Here
100
my $prepared_letter;
100
my $prepared_letter;
101
101
102
my $sth =
102
my $sth =
103
  $dbh->prepare(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test',?,'Test','Test',?)});
103
  $dbh->prepare(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test',?,'Test',?,?)});
104
104
105
$sth->execute( "TEST_PATRON", "[% borrower.id %]" );
105
$sth->execute( "TEST_PATRON", "[% borrower.firstname %]", "[% borrower.id %]" );
106
$prepared_letter = GetPreparedLetter(
106
$prepared_letter = GetPreparedLetter(
107
    (
107
    (
108
        module      => 'test',
108
        module      => 'test',
Lines 112-118 $prepared_letter = GetPreparedLetter( Link Here
112
        },
112
        },
113
    )
113
    )
114
);
114
);
115
is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with scalar' );
115
is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with scalar for content' );
116
is( $prepared_letter->{title}, $patron->{firstname}, 'Patron object used correctly with scalar for title' );
116
117
117
$prepared_letter = GetPreparedLetter(
118
$prepared_letter = GetPreparedLetter(
118
    (
119
    (
Lines 123-129 $prepared_letter = GetPreparedLetter( Link Here
123
        },
124
        },
124
    )
125
    )
125
);
126
);
126
is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with hashref' );
127
is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with hashref for content' );
128
is( $prepared_letter->{title}, $patron->{firstname}, 'Patron object used correctly with hashref for title' );
127
129
128
$prepared_letter = GetPreparedLetter(
130
$prepared_letter = GetPreparedLetter(
129
    (
131
    (
Lines 134-142 $prepared_letter = GetPreparedLetter( Link Here
134
        },
136
        },
135
    )
137
    )
136
);
138
);
137
is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with arrayref' );
139
is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with arrayref for content' );
140
is( $prepared_letter->{title}, $patron->{firstname}, 'Patron object used correctly with arrayref for title' );
138
141
139
$sth->execute( "TEST_BIBLIO", "[% biblio.id %]" );
142
$sth->execute( "TEST_BIBLIO", "[% biblio.title %]", "[% biblio.id %]" );
140
$prepared_letter = GetPreparedLetter(
143
$prepared_letter = GetPreparedLetter(
141
    (
144
    (
142
        module      => 'test',
145
        module      => 'test',
Lines 146-154 $prepared_letter = GetPreparedLetter( Link Here
146
        },
149
        },
147
    )
150
    )
148
);
151
);
149
is( $prepared_letter->{content}, $item->biblionumber, 'Biblio object used correctly' );
152
is( $prepared_letter->{content}, $item->biblionumber, 'Biblio object used correctly for content' );
153
is( $prepared_letter->{title}, $item->biblio->title, 'Biblio object used correctly for title' );
150
154
151
$sth->execute( "TEST_LIBRARY", "[% branch.id %]" );
155
$sth->execute( "TEST_LIBRARY", "[% branch.branchcode %]", "[% branch.id %]" );
152
$prepared_letter = GetPreparedLetter(
156
$prepared_letter = GetPreparedLetter(
153
    (
157
    (
154
        module      => 'test',
158
        module      => 'test',
Lines 158-166 $prepared_letter = GetPreparedLetter( Link Here
158
        },
162
        },
159
    )
163
    )
160
);
164
);
161
is( $prepared_letter->{content}, $library->{branchcode}, 'Library object used correctly' );
165
is( $prepared_letter->{content}, $library->{branchcode}, 'Library object used correctly for content' );
166
is( $prepared_letter->{title}, $library->{branchcode}, 'Library object used correctly for title' );
162
167
163
$sth->execute( "TEST_ITEM", "[% item.id %]" );
168
$sth->execute( "TEST_ITEM", "[% item.barcode %]", "[% item.id %]" );
164
$prepared_letter = GetPreparedLetter(
169
$prepared_letter = GetPreparedLetter(
165
    (
170
    (
166
        module      => 'test',
171
        module      => 'test',
Lines 170-178 $prepared_letter = GetPreparedLetter( Link Here
170
        },
175
        },
171
    )
176
    )
172
);
177
);
173
is( $prepared_letter->{content}, $item->id(), 'Item object used correctly' );
178
is( $prepared_letter->{content}, $item->id(), 'Item object used correctly for content' );
179
is( $prepared_letter->{title}, $item->barcode, 'Item object used correctly for title' );
174
180
175
$sth->execute( "TEST_NEWS", "[% news.id %]" );
181
$sth->execute( "TEST_NEWS", "[% news.id %]", "[% news.id %]" );
176
$prepared_letter = GetPreparedLetter(
182
$prepared_letter = GetPreparedLetter(
177
    (
183
    (
178
        module      => 'test',
184
        module      => 'test',
Lines 182-190 $prepared_letter = GetPreparedLetter( Link Here
182
        },
188
        },
183
    )
189
    )
184
);
190
);
185
is( $prepared_letter->{content}, $news->id(), 'News object used correctly' );
191
is( $prepared_letter->{content}, $news->id(), 'News object used correctly for content' );
192
is( $prepared_letter->{title}, $news->id(), 'News object used correctly for title' );
186
193
187
$sth->execute( "TEST_HOLD", "[% hold.id %]" );
194
$sth->execute( "TEST_HOLD", "[% hold.borrowernumber %]", "[% hold.id %]" );
188
$prepared_letter = GetPreparedLetter(
195
$prepared_letter = GetPreparedLetter(
189
    (
196
    (
190
        module      => 'test',
197
        module      => 'test',
Lines 194-200 $prepared_letter = GetPreparedLetter( Link Here
194
        },
201
        },
195
    )
202
    )
196
);
203
);
197
is( $prepared_letter->{content}, $hold->id(), 'Hold object used correctly' );
204
is( $prepared_letter->{content}, $hold->id(), 'Hold object used correctly for content' );
205
is( $prepared_letter->{title}, $hold->borrowernumber, 'Hold object used correctly for title' );
198
206
199
eval {
207
eval {
200
    $prepared_letter = GetPreparedLetter(
208
    $prepared_letter = GetPreparedLetter(
Lines 227-233 $prepared_letter = GetPreparedLetter( Link Here
227
);
235
);
228
is( $prepared_letter->{content}, $hold->id(), 'Hold object used correctly' );
236
is( $prepared_letter->{content}, $hold->id(), 'Hold object used correctly' );
229
237
230
$sth->execute( "TEST_SERIAL", "[% serial.id %]" );
238
$sth->execute( "TEST_SERIAL", "[% serial.id %]", "[% serial.id %]" );
231
$prepared_letter = GetPreparedLetter(
239
$prepared_letter = GetPreparedLetter(
232
    (
240
    (
233
        module      => 'test',
241
        module      => 'test',
Lines 239-245 $prepared_letter = GetPreparedLetter( Link Here
239
);
247
);
240
is( $prepared_letter->{content}, $serial->id(), 'Serial object used correctly' );
248
is( $prepared_letter->{content}, $serial->id(), 'Serial object used correctly' );
241
249
242
$sth->execute( "TEST_SUBSCRIPTION", "[% subscription.id %]" );
250
$sth->execute( "TEST_SUBSCRIPTION", "[% subscription.id %]", "[% subscription.id %]" );
243
$prepared_letter = GetPreparedLetter(
251
$prepared_letter = GetPreparedLetter(
244
    (
252
    (
245
        module      => 'test',
253
        module      => 'test',
Lines 251-257 $prepared_letter = GetPreparedLetter( Link Here
251
);
259
);
252
is( $prepared_letter->{content}, $subscription->id(), 'Subscription object used correctly' );
260
is( $prepared_letter->{content}, $subscription->id(), 'Subscription object used correctly' );
253
261
254
$sth->execute( "TEST_SUGGESTION", "[% suggestion.id %]" );
262
$sth->execute( "TEST_SUGGESTION", "[% suggestion.id %]", "[% suggestion.id %]" );
255
$prepared_letter = GetPreparedLetter(
263
$prepared_letter = GetPreparedLetter(
256
    (
264
    (
257
        module      => 'test',
265
        module      => 'test',
Lines 263-269 $prepared_letter = GetPreparedLetter( Link Here
263
);
271
);
264
is( $prepared_letter->{content}, $suggestion->id(), 'Suggestion object used correctly' );
272
is( $prepared_letter->{content}, $suggestion->id(), 'Suggestion object used correctly' );
265
273
266
$sth->execute( "TEST_ISSUE", "[% checkout.id %]" );
274
$sth->execute( "TEST_ISSUE", "[% checkout.id %]", "[% checkout.id %]" );
267
$prepared_letter = GetPreparedLetter(
275
$prepared_letter = GetPreparedLetter(
268
    (
276
    (
269
        module      => 'test',
277
        module      => 'test',
Lines 275-281 $prepared_letter = GetPreparedLetter( Link Here
275
);
283
);
276
is( $prepared_letter->{content}, $checkout->id(), 'Checkout object used correctly' );
284
is( $prepared_letter->{content}, $checkout->id(), 'Checkout object used correctly' );
277
285
278
$sth->execute( "TEST_MODIFICATION", "[% patron_modification.id %]" );
286
$sth->execute( "TEST_MODIFICATION", "[% patron_modification.id %]", "[% patron_modification.id %]" );
279
$prepared_letter = GetPreparedLetter(
287
$prepared_letter = GetPreparedLetter(
280
    (
288
    (
281
        module      => 'test',
289
        module      => 'test',
282
- 

Return to bug 26745