|
Lines 211-254
subtest 'subscription' => sub {
Link Here
|
| 211 |
}; |
211 |
}; |
| 212 |
|
212 |
|
| 213 |
subtest 'suggestions() tests' => sub { |
213 |
subtest 'suggestions() tests' => sub { |
|
|
214 |
|
| 214 |
plan tests => 4; |
215 |
plan tests => 4; |
| 215 |
|
216 |
|
| 216 |
$schema->storage->txn_begin; |
217 |
$schema->storage->txn_begin; |
|
|
218 |
|
| 217 |
my $o = $builder->build_object( |
219 |
my $o = $builder->build_object( |
| 218 |
{ |
220 |
{ |
| 219 |
class => 'Koha::Acquisition::Orders', |
221 |
class => 'Koha::Acquisition::Orders', |
| 220 |
} |
222 |
} |
| 221 |
); |
223 |
); |
| 222 |
|
224 |
|
| 223 |
my $order = Koha::Acquisition::Orders->find( $o->ordernumber ); |
|
|
| 224 |
is( |
225 |
is( |
| 225 |
ref( $order->suggestions ), 'Koha::Suggestions', |
226 |
ref( $o->suggestions ), 'Koha::Suggestions', |
| 226 |
'->suggestions should return a Koha::Suggestions object' |
227 |
'->suggestions should return a Koha::Suggestions object' |
| 227 |
); |
228 |
); |
| 228 |
is( |
229 |
is( |
| 229 |
$order->suggestions->count, 0, |
230 |
$o->suggestions->count, 0, |
| 230 |
'->suggestions should return empty set if no linked suggestion' |
231 |
'->suggestions should return empty set if no linked suggestion' |
| 231 |
); |
232 |
); |
| 232 |
|
233 |
|
| 233 |
$o = $builder->build_object( |
234 |
# Add a few suggestions |
| 234 |
{ |
235 |
foreach ( 1..3 ) { |
| 235 |
class => 'Koha::Acquisition::Orders', |
236 |
$builder->build_object( |
| 236 |
} |
237 |
{ |
| 237 |
); |
238 |
class => 'Koha::Suggestions', |
| 238 |
$o = $builder->build_object( |
239 |
value => { ordernumber => $o->id } |
| 239 |
{ |
240 |
} |
| 240 |
class => 'Koha::Suggestions', |
241 |
); |
| 241 |
value => { ordernumber => $o->id } |
242 |
} |
| 242 |
} |
|
|
| 243 |
); |
| 244 |
|
243 |
|
| 245 |
$order = Koha::Acquisition::Orders->find( $o->ordernumber ); |
|
|
| 246 |
is( |
244 |
is( |
| 247 |
ref( $order->suggestions ), 'Koha::Suggestions', |
245 |
ref( $o->suggestions ), 'Koha::Suggestions', |
| 248 |
'->suggestions should return a Koha::Suggestions object' |
246 |
'->suggestions should return a Koha::Suggestions object' |
| 249 |
); |
247 |
); |
| 250 |
is( |
248 |
is( |
| 251 |
$order->suggestions->count, 1, |
249 |
$o->suggestions->count, 3, |
| 252 |
'->suggestions should return linked suggestions' |
250 |
'->suggestions should return linked suggestions' |
| 253 |
); |
251 |
); |
| 254 |
|
252 |
|
| 255 |
- |
|
|