3 use Test::More tests => 13;
7 use_ok 'Support::TestSetup';
8 use_ok 'SL::Controller::Helper::ParseFilter';
10 Support::TestSetup::login();
11 my ($filter, $expected);
14 my $got = { parse_filter($_[0]) };
20 print STDERR "expected => ", Dumper($_[1]), "\ngot: => ", Dumper($got), $/;
43 query => [ 'customer.name' => 'rainer' ],
44 with_objects => [ 'customer' ],
45 }, 'joining customers';
54 query => [ 'customer.chart.accno' => 'test' ],
55 with_objects => [ 'customer', 'chart' ],
59 'customer:substr' => 'Meyer'
61 query => [ customer => '%Meyer%' ]
62 }, 'simple filter substr';
65 'customer::ilike' => 'Meyer'
67 query => [ customer => { ilike => 'Meyer' } ]
68 }, 'simple method ilike';
73 'accno:tail::like' => '1200'
78 query => [ 'customer.chart.accno' => { like => '%1200' } ],
79 with_objects => ['customer', 'chart' ],
94 'invoice.customer.name' => 'test',
95 'customer.name' => 'test',
101 }, 'object in more than one relationship';
104 'orddate:date::' => 'lt',
105 'orddate:date' => '20.3.2010',
108 'orddate' => { 'lt' => isa('DateTime') }
111 }, 'method dispatch and date constructor';
118 query => [ id => [ 123,125,157 ] ],
119 }, 'arrays as value';
122 'sellprice:number' => [
123 '123,4', '2,34', '0,4',
127 sellprice => [ 123.4, 2.34, 0.4 ],
129 }, 'arrays with filter';