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

(-)a/Koha/Object.pm (+14 lines)
Lines 107-112 sub _new_from_dbic { Link Here
107
107
108
}
108
}
109
109
110
=head3 Koha::Object->_new_from_hashref();
111
112
my $object = Koha::Object->_new_from_hashref($hashref_row);
113
114
=cut
115
116
sub _new_from_hashref {
117
    my ( $class, $hashref ) = @_;
118
119
    my $result = Koha::Database->new->schema->resultset( $class->_type )->new( $hashref );
120
121
    $class->_new_from_dbic( $result );
122
}
123
110
=head3 $object->store();
124
=head3 $object->store();
111
125
112
Saves the object in storage.
126
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 => 19;
20
use Test::More tests => 20;
21
use Test::Exception;
21
use Test::Exception;
22
use Test::Warn;
22
use Test::Warn;
23
use DateTime;
23
use DateTime;
Lines 818-820 subtest 'prefetch_whitelist() tests' => sub { Link Here
818
818
819
    $schema->storage->txn_rollback;
819
    $schema->storage->txn_rollback;
820
};
820
};
821
- 
821
822
subtest 'new_from_hashref' => sub {
823
    plan tests => 1;
824
825
    $schema->storage->txn_begin;
826
827
    my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
828
    my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
829
830
    my $patron1 = Koha::Patron->new({categorycode => $categorycode, branchcode => $branchcode })->store;
831
832
    my $hashref = $patron1->unblessed;
833
834
    my $patron2 = Koha::Patron->_new_from_hashref( $hashref );
835
836
    is( $patron1->id, $patron2->id, "Borrowernumbers match using new_from_hashref");
837
838
    $schema->storage->txn_rollback;
839
};

Return to bug 22622