X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F06order_by.t;h=440517f0869655d72dca5b0d60db06d3c2b297cc;hb=4f30591bc0678f8a5d657e79c6985606b064cd1d;hp=a8fc1c7ae32e3476e95b37f760008c3684794df4;hpb=96449e8ea5159e5448ebfc81dfa200dc674f366b;p=dbsrgits%2FSQL-Abstract.git diff --git a/t/06order_by.t b/t/06order_by.t index a8fc1c7..440517f 100644 --- a/t/06order_by.t +++ b/t/06order_by.t @@ -6,10 +6,7 @@ use Test::More; use SQL::Abstract; -use FindBin; -use lib "$FindBin::Bin"; -use TestSqlAbstract; - +use SQL::Abstract::Test import => ['is_same_sql_bind']; my @cases = ( { @@ -22,11 +19,21 @@ my @cases = expects => ' ORDER BY colA', expects_quoted => ' ORDER BY `colA`', }, + { # it may look odd, but this is the desired behaviour (mst) + given => 'colA DESC', + expects => ' ORDER BY colA DESC', + expects_quoted => ' ORDER BY `colA DESC`', + }, { given => [qw/colA colB/], expects => ' ORDER BY colA, colB', expects_quoted => ' ORDER BY `colA`, `colB`', }, + { # it may look odd, but this is the desired behaviour (mst) + given => ['colA ASC', 'colB DESC'], + expects => ' ORDER BY colA ASC, colB DESC', + expects_quoted => ' ORDER BY `colA ASC`, `colB DESC`', + }, { given => {-asc => 'colA'}, expects => ' ORDER BY colA ASC', @@ -47,13 +54,19 @@ my @cases = expects => ' ORDER BY colA, colB DESC', expects_quoted => ' ORDER BY `colA`, `colB` DESC', }, + { + given => undef, + expects => '', + expects_quoted => '', + }, ); -my $sql = SQL::Abstract->new; -my $sqlq = SQL::Abstract->new({quote_char => '`'}); plan tests => (scalar(@cases) * 2); +my $sql = SQL::Abstract->new; +my $sqlq = SQL::Abstract->new({quote_char => '`'}); + for my $case( @cases){ is($sql->_order_by($case->{given}), $case->{expects}); is($sqlq->_order_by($case->{given}), $case->{expects_quoted});