|
Lines 285-291
subtest 'Test build with NULL values' => sub {
Link Here
|
| 285 |
|
285 |
|
| 286 |
|
286 |
|
| 287 |
subtest 'Tests for delete method' => sub { |
287 |
subtest 'Tests for delete method' => sub { |
| 288 |
plan tests => 12; |
288 |
plan tests => 11; |
| 289 |
|
289 |
|
| 290 |
$schema->storage->txn_begin; |
290 |
$schema->storage->txn_begin; |
| 291 |
|
291 |
|
|
Lines 304-326
subtest 'Tests for delete method' => sub {
Link Here
|
| 304 |
|
304 |
|
| 305 |
|
305 |
|
| 306 |
# Test delete in table without primary key (..) |
306 |
# Test delete in table without primary key (..) |
| 307 |
is( $schema->source('TmpHoldsqueue')->primary_columns, 0, |
307 |
is( $schema->source('AccountCreditTypesBranch')->primary_columns, 0, |
| 308 |
'Table without primary key detected' ); |
308 |
'Table without primary key detected' ); |
| 309 |
my $bibno = $builder->build_sample_biblio->biblionumber; |
309 |
my $cnt1 = $schema->resultset('AccountCreditTypesBranch')->count; |
| 310 |
my $cnt1 = $schema->resultset('TmpHoldsqueue')->count; |
310 |
# Insert a new record in AccountCreditTypesBranch with that biblionumber |
| 311 |
# Insert a new record in TmpHoldsqueue with that biblionumber |
311 |
my $rec = $builder->build({ source => 'AccountCreditTypesBranch' }); |
| 312 |
my $val = { biblionumber => $bibno }; |
312 |
my $cnt2 = $schema->resultset('AccountCreditTypesBranch')->count; |
| 313 |
my $rec = $builder->build({ source => 'TmpHoldsqueue', value => $val }); |
|
|
| 314 |
my $cnt2 = $schema->resultset('TmpHoldsqueue')->count; |
| 315 |
is( defined($rec) && $cnt2 == $cnt1 + 1 , 1, 'Created a record' ); |
313 |
is( defined($rec) && $cnt2 == $cnt1 + 1 , 1, 'Created a record' ); |
| 316 |
is( $builder->delete({ source => 'TmpHoldsqueue', records => $rec }), |
314 |
is( $builder->delete({ source => 'AccountCreditTypesBranch', records => $rec }), |
| 317 |
undef, 'delete returns undef' ); |
315 |
undef, 'delete returns undef' ); |
| 318 |
is( $rec->{biblionumber}, $bibno, 'Hash value untouched' ); |
316 |
is( $schema->resultset('AccountCreditTypesBranch')->count, $cnt2, |
| 319 |
is( $schema->resultset('TmpHoldsqueue')->count, $cnt2, |
|
|
| 320 |
"Method did not delete record in table without PK" ); |
317 |
"Method did not delete record in table without PK" ); |
| 321 |
|
318 |
|
| 322 |
# Test delete with NULL values |
319 |
# Test delete with NULL values |
| 323 |
$val = { branchcode => undef }; |
320 |
my $val = { branchcode => undef }; |
| 324 |
is( $builder->delete({ source => 'Branch', records => $val }), 0, |
321 |
is( $builder->delete({ source => 'Branch', records => $val }), 0, |
| 325 |
'delete returns zero for an undef search with one key' ); |
322 |
'delete returns zero for an undef search with one key' ); |
| 326 |
$val = { module_bit => 1, #catalogue |
323 |
$val = { module_bit => 1, #catalogue |
| 327 |
- |
|
|