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

(-)a/Koha/Object.pm (-2 / +4 lines)
Lines 48-53 This class must always be subclassed. Link Here
48
my $object = Koha::Object->new();
48
my $object = Koha::Object->new();
49
my $object = Koha::Object->new($attributes);
49
my $object = Koha::Object->new($attributes);
50
50
51
Note that this cannot be used to retrieve record from the DB.
52
51
=cut
53
=cut
52
54
53
sub new {
55
sub new {
Lines 183-189 sub set { Link Here
183
    my @columns = @{$self->_columns()};
185
    my @columns = @{$self->_columns()};
184
186
185
    foreach my $p ( keys %$properties ) {
187
    foreach my $p ( keys %$properties ) {
186
        unless ( $p ~~ @columns ) {
188
        unless ( grep {/^$p$/} @columns ) {
187
            carp("No property $p!");
189
            carp("No property $p!");
188
            return 0;
190
            return 0;
189
        }
191
        }
Lines 252-258 sub AUTOLOAD { Link Here
252
254
253
    my @columns = @{$self->_columns()};
255
    my @columns = @{$self->_columns()};
254
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
256
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
255
    if ( $method ~~ @columns ) {
257
    if ( grep {/^$method$/} @columns ) {
256
        if ( @_ ) {
258
        if ( @_ ) {
257
            return $self->_result()->set_column( $method, @_ );
259
            return $self->_result()->set_column( $method, @_ );
258
        } else {
260
        } else {
(-)a/Koha/Objects.pm (-6 / +6 lines)
Lines 48-54 This class must be subclassed. Link Here
48
48
49
=head3 Koha::Objects->new();
49
=head3 Koha::Objects->new();
50
50
51
my $object = Koha::Object->new();
51
my $object = Koha::Objects->new();
52
52
53
=cut
53
=cut
54
54
Lines 61-67 sub new { Link Here
61
61
62
=head3 Koha::Objects->new_from_dbic();
62
=head3 Koha::Objects->new_from_dbic();
63
63
64
my $object = Koha::Object->new_from_dbic( $resultset );
64
my $object = Koha::Objects->new_from_dbic( $resultset );
65
65
66
=cut
66
=cut
67
67
Lines 74-81 sub new_from_dbic { Link Here
74
74
75
=head3 Koha::Objects->find();
75
=head3 Koha::Objects->find();
76
76
77
my $object = Koha::Object->find($id);
77
my $object = Koha::Objects->find($id);
78
my $object = Koha::Object->find( { keypart1 => $keypart1, keypart2 => $keypart2 } );
78
my $object = Koha::Objects->find( { keypart1 => $keypart1, keypart2 => $keypart2 } );
79
79
80
=cut
80
=cut
81
81
Lines 91-97 sub find { Link Here
91
91
92
=head3 Koha::Objects->search();
92
=head3 Koha::Objects->search();
93
93
94
my @objects = Koha::Object->search($params);
94
my @objects = Koha::Objects->search($params);
95
95
96
=cut
96
=cut
97
97
Lines 114-120 sub search { Link Here
114
114
115
=head3 Koha::Objects->count();
115
=head3 Koha::Objects->count();
116
116
117
my @objects = Koha::Object->count($params);
117
my @objects = Koha::Objects->count($params);
118
118
119
=cut
119
=cut
120
120
(-)a/t/db_dependent/Borrower.t (-6 / +9 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 12;
20
use Test::More tests => 13;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use C4::Context;
23
use C4::Context;
Lines 45-56 $object->branchcode( $branchcode ); Link Here
45
$object->surname("Test Surname");
45
$object->surname("Test Surname");
46
$object->store();
46
$object->store();
47
47
48
my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $object->borrowernumber() );
49
is( $borrower->surname(), "Test Surname", "Object found in database" );
50
51
is( $object->in_storage, 1, "Object is now stored" );
48
is( $object->in_storage, 1, "Object is now stored" );
52
49
50
my $borrowernumber = $object->borrowernumber;
51
52
my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
53
is( $borrower->surname(), "Test Surname", "Object found in database" );
54
53
is( $object->is_changed(), 0, "Object is unchanged" );
55
is( $object->is_changed(), 0, "Object is unchanged" );
56
$object->surname("Test Surname");
57
is( $object->is_changed(), 0, "Object is still unchanged" );
54
$object->surname("Test Surname 2");
58
$object->surname("Test Surname 2");
55
is( $object->is_changed(), 1, "Object is changed" );
59
is( $object->is_changed(), 1, "Object is changed" );
56
60
Lines 63-69 $object->store(); Link Here
63
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
67
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
64
68
65
$object->delete();
69
$object->delete();
66
$borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $object->borrowernumber() );
70
$borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
67
ok( ! $borrower, "Object no longer found in database" );
71
ok( ! $borrower, "Object no longer found in database" );
68
is( $object->in_storage, 0, "Object is not in storage" );
72
is( $object->in_storage, 0, "Object is not in storage" );
69
73
70
- 

Return to bug 10363