3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test::More tests => 1;
22 use C4::Utils::DataTables;
25 use t::lib::TestBuilder;
29 my $schema = Koha::Database->new->schema;
30 $schema->storage->txn_begin;
32 my $builder = t::lib::TestBuilder->new;
34 subtest 'dt_build_orderby' => sub {
40 mDataProp_5 => "branch",
41 name_sorton => "borrowers.surname borrowers.firstname",
45 mDataProp_2 => "name",
46 branch_sorton => "branches.branchname",
49 my $orderby = dt_build_orderby($dt_params);
50 is( $orderby, " ORDER BY `branches`.`branchname` ASC,`borrowers`.`surname` DESC,`borrowers`.`firstname` DESC ", 'ORDER BY has been correctly built' );
56 mDataProp_3 => "branch,somethingelse",
59 $orderby = dt_build_orderby($dt_params);
60 is( $orderby, " ORDER BY `branches`.`branchname` ASC,`borrowers`.`surname` DESC,`borrowers`.`firstname` DESC ", 'ORDER BY has been correctly built, even with invalid stuff');