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

(-)a/Koha/UploadedFile.pm (+73 lines)
Line 0 Link Here
1
package Koha::UploadedFile;
2
3
# Copyright Rijksmuseum 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
#use Koha::Database;
23
24
use parent qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::UploadedFile - Koha::Object class for single uploaded file
29
30
=head1 SYNOPSIS
31
32
use Koha::UploadedFile;
33
34
=head1 DESCRIPTION
35
36
Description
37
38
=head1 METHODS
39
40
=head2 INSTANCE METHODS
41
42
=head3 delete
43
44
Delete uploaded file (to be extended)
45
46
=cut
47
48
sub delete {
49
    my ( $self, $params ) = @_;
50
    $self->SUPER::delete( $params );
51
}
52
53
=head2 CLASS METHODS
54
55
=head3 _type
56
57
Returns name of corresponding DBIC resultset
58
59
=cut
60
61
sub _type {
62
    return 'UploadedFile';
63
}
64
65
=head1 AUTHOR
66
67
Marcel de Rooy (Rijksmuseum)
68
69
Koha Development Team
70
71
=cut
72
73
1;
(-)a/Koha/UploadedFiles.pm (+84 lines)
Line 0 Link Here
1
package Koha::UploadedFiles;
2
3
# Copyright Rijksmuseum 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
#use Koha::Database;
23
use Koha::UploadedFile;
24
25
use parent qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::UploadedFiles - Koha::Objects class for uploaded files
30
31
=head1 SYNOPSIS
32
33
use Koha::UploadedFiles;
34
35
=head1 DESCRIPTION
36
37
Description
38
39
=head1 METHODS
40
41
=head2 INSTANCE METHODS
42
43
=head3 delete
44
45
Delete uploaded files
46
47
=cut
48
49
sub delete {
50
    my ( $self, $params ) = @_;
51
    $self->SUPER::delete( $params );
52
}
53
54
=head2 CLASS METHODS
55
56
=head3 _type
57
58
Returns name of corresponding DBIC resultset
59
60
=cut
61
62
sub _type {
63
    return 'UploadedFile';
64
}
65
66
=head3 object_class
67
68
Returns name of corresponding Koha object class
69
70
=cut
71
72
sub object_class {
73
    return 'Koha::UploadedFile';
74
}
75
76
=head1 AUTHOR
77
78
Marcel de Rooy (Rijksmuseum)
79
80
Koha Development Team
81
82
=cut
83
84
1;
(-)a/t/db_dependent/Upload.t (-2 / +19 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use File::Temp qw/ tempdir /;
4
use File::Temp qw/ tempdir /;
5
use Test::More tests => 8;
5
use Test::More tests => 9;
6
6
7
use Test::MockModule;
7
use Test::MockModule;
8
use t::lib::Mocks;
8
use t::lib::Mocks;
Lines 11-16 use t::lib::TestBuilder; Link Here
11
use C4::Context;
11
use C4::Context;
12
use Koha::Database;
12
use Koha::Database;
13
use Koha::Upload;
13
use Koha::Upload;
14
use Koha::UploadedFiles;
14
15
15
my $schema  = Koha::Database->new->schema;
16
my $schema  = Koha::Database->new->schema;
16
$schema->storage->txn_begin;
17
$schema->storage->txn_begin;
Lines 204-209 sub test08 { # allows_add_by Link Here
204
        1, 'Patron is still allowed to add uploaded files' );
205
        1, 'Patron is still allowed to add uploaded files' );
205
}
206
}
206
207
208
# Additional tests for Koha::UploadedFiles
209
# TODO Rearrange the tests after this migration
210
subtest 'Some basic CRUD testing' => sub {
211
    plan tests => 2;
212
213
    # Test find and attribute id, delete and search
214
    my $builder = t::lib::TestBuilder->new;
215
    my $upload01 = $builder->build({ source => 'UploadedFile' });
216
    my $found = Koha::UploadedFiles->find( $upload01->{id} );
217
    is( $found->id, $upload01->{id}, 'Koha::Object returns id' );
218
    $found->delete;
219
    $found = Koha::UploadedFiles->search(
220
        { id => $upload01->{id} },
221
    );
222
    is( $found->count, 0, 'Delete seems successful' );
223
};
224
207
sub newCGI {
225
sub newCGI {
208
    my ( $class, $hook ) = @_;
226
    my ( $class, $hook ) = @_;
209
    my $read = 0;
227
    my $read = 0;
210
- 

Return to bug 17501