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

(-)a/Koha/Object.pm (+14 lines)
Lines 106-111 sub _new_from_dbic { Link Here
106
106
107
}
107
}
108
108
109
=head3 Koha::Object->_new_from_hashref();
110
111
my $object = Koha::Object->_new_from_hashref($hashref_row);
112
113
=cut
114
115
sub _new_from_hashref {
116
    my ( $class, $hashref ) = @_;
117
118
    my $result = Koha::Database->new->schema->resultset( $class->_type )->new( $hashref );
119
120
    $class->_new_from_dbic( $result );
121
}
122
109
=head3 $object->store();
123
=head3 $object->store();
110
124
111
Saves the object in storage.
125
Saves the object in storage.
(-)a/t/db_dependent/Koha/Object.t (-2 / +20 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 11;
20
use Test::More tests => 12;
21
use Test::Exception;
21
use Test::Exception;
22
use Test::Warn;
22
use Test::Warn;
23
use DateTime;
23
use DateTime;
Lines 415-417 subtest 'unblessed_all_relateds' => sub { Link Here
415
415
416
    $schema->storage->txn_rollback;
416
    $schema->storage->txn_rollback;
417
};
417
};
418
- 
418
419
subtest 'new_from_hashref' => sub {
420
    plan tests => 1;
421
422
    $schema->storage->txn_begin;
423
424
    my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
425
    my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
426
427
    my $patron1 = Koha::Patron->new({categorycode => $categorycode, branchcode => $branchcode })->store;
428
429
    my $hashref = $patron1->unblessed;
430
431
    my $patron2 = Koha::Patron->_new_from_hashref( $hashref );
432
433
    is( $patron1->id, $patron2->id, "Borrowernumbers match using new_from_hashref");
434
435
    $schema->storage->txn_rollback;
436
};

Return to bug 22622