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

(-)a/Koha/ClassificationSort.pm (+44 lines)
Line 0 Link Here
1
package Koha::ClassificationSort;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::ClassificationSort - Koha Classfication Sorting Rule Object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'ClassSortRule';
42
}
43
44
1;
(-)a/Koha/ClassificationSorters.pm (+50 lines)
Line 0 Link Here
1
package Koha::ClassificationSorters;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use Koha::ClassificationSorters;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::ClassificationSorters - Koha Classification Sort Rules Object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'ClassSortRule';
44
}
45
46
sub object_class {
47
    return 'Koha::ClassificationSort';
48
}
49
50
1;
(-)a/Koha/ClassificationSource.pm (+44 lines)
Line 0 Link Here
1
package Koha::ClassificationSource;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::ClassificationSource - Koha Classfication Source Object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'ClassSource';
42
}
43
44
1;
(-)a/Koha/ClassificationSources.pm (+50 lines)
Line 0 Link Here
1
package Koha::ClassificationSources;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use Koha::ClassificationSource;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::ClassificationSources - Koha Classification Source Object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'ClassSource';
44
}
45
46
sub object_class {
47
    return 'Koha::ClassificationSource';
48
}
49
50
1;
(-)a/t/db_dependent/Koha/ClassificationSorters.t (+57 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2017 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 4;
23
24
use Koha::Database;
25
26
use Koha::ClassificationSorters;
27
use Koha::ClassificationSort;
28
29
use t::lib::TestBuilder;
30
31
my $schema = Koha::Database->new->schema;
32
$schema->storage->txn_begin;
33
34
my $builder = t::lib::TestBuilder->new;
35
my $nb_of_class_sorters = Koha::ClassificationSorters->search->count;
36
my $new_cs_1 = Koha::ClassificationSort->new({
37
    class_sort_rule => 'sort_rule1',
38
    description => 'a_sort_test_1',
39
    sort_routine => 'lcc',
40
})->store;
41
my $new_cs_2 = Koha::ClassificationSort->new({
42
    class_sort_rule => 'sort_rule2',
43
    description => 'a_sort_test_2',
44
    sort_routine => 'dewey',
45
})->store;
46
47
is( $new_cs_1->class_sort_rule, 'sort_rule1', 'Adding a new classification sort should have set the class_sort_rule');
48
is( Koha::ClassificationSorters->search->count, $nb_of_class_sorters + 2, 'The 2 classification sorters should have been added' );
49
50
my $retrieved_cs_1 = Koha::ClassificationSorters->find( $new_cs_1->class_sort_rule );
51
is( $retrieved_cs_1->description, $new_cs_1->description, 'Find a sorter by class_sort_rule should return the correct source' );
52
53
$retrieved_cs_1->delete;
54
is( Koha::ClassificationSorters->search->count, $nb_of_class_sorters + 1, 'Delete should have deleted the sort' );
55
56
$schema->storage->txn_rollback;
57
(-)a/t/db_dependent/Koha/ClassificationSources.t (-1 / +61 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2017 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 4;
23
24
use Koha::Database;
25
26
use Koha::ClassificationSources;
27
use Koha::ClassificationSource;
28
29
use t::lib::TestBuilder;
30
31
my $schema = Koha::Database->new->schema;
32
$schema->storage->txn_begin;
33
34
my $builder = t::lib::TestBuilder->new;
35
my $class_sort_1 = $builder->build({ source=>'ClassSortRule' });
36
my $class_sort_2 = $builder->build({ source=>'ClassSortRule' });
37
my $nb_of_class_sources = Koha::ClassificationSources->search->count;
38
my $new_cs_1 = Koha::ClassificationSource->new({
39
    cn_source => 'source_1',
40
    description => 'a_test_1',
41
    used => '1',
42
    class_sort_rule => $class_sort_1->{class_sort_rule},#'sort_rule_1',
43
})->store;
44
my $new_cs_2 = Koha::ClassificationSource->new({
45
    cn_source => 'source_2',
46
    description => 'a_test_2',
47
    used => '0',
48
    class_sort_rule => $class_sort_2->{class_sort_rule},#'sort_rule_1',
49
})->store;
50
51
is( $new_cs_1->cn_source, 'source_1', 'Adding a new classification should have set the cn_source');
52
is( Koha::ClassificationSources->search->count, $nb_of_class_sources + 2, 'The 2 classifcations should have been added' );
53
54
my $retrieved_cs_1 = Koha::ClassificationSources->find( $new_cs_1->cn_source );
55
is( $retrieved_cs_1->description, $new_cs_1->description, 'Find a source by cn_source should return the correct source' );
56
57
$retrieved_cs_1->delete;
58
is( Koha::ClassificationSources->search->count, $nb_of_class_sources + 1, 'Delete should have deleted the classification' );
59
60
$schema->storage->txn_rollback;
61

Return to bug 19929