3 use Test::More tests => 13;
7 use_ok 'Support::TestSetup';
8 use_ok 'SL::Controller::Helper::ParseFilter';
10 undef *::any; # Test::Deep exports any (for junctions) and MoreCommon exports any (like in List::Moreutils)
12 Support::TestSetup::login();
13 my ($filter, $expected);
16 my $got = { parse_filter($_[0]) };
22 print STDERR "expected => ", Dumper($_[1]), "\ngot: => ", Dumper($got), $/;
44 query => [ 'customer.name' => 'rainer' ],
45 with_objects => [ 'customer' ],
46 }, 'joining customers';
55 query => [ 'customer.chart.accno' => 'test' ],
56 with_objects => bag( 'customer', 'chart' ),
60 'customer:substr' => 'Meyer'
62 query => [ customer => '%Meyer%' ]
63 }, 'simple filter substr';
66 'customer::ilike' => 'Meyer'
68 query => [ customer => { ilike => 'Meyer' } ]
69 }, 'simple method ilike';
74 'accno:tail::like' => '1200'
79 query => [ 'customer.chart.accno' => { like => '%1200' } ],
80 with_objects => bag('customer', 'chart' ),
95 'invoice.customer.name' => 'test',
96 'customer.name' => 'test',
98 'with_objects' => bag( 'invoice', 'customer' )
99 }, 'object in more than one relationship';
102 'orddate:date::' => 'lt',
103 'orddate:date' => '20.3.2010',
106 'orddate' => { 'lt' => isa('DateTime') }
109 }, 'method dispatch and date constructor';
116 query => [ id => [ 123,125,157 ] ],
117 }, 'arrays as value';
120 'sellprice:number' => [
121 '123,4', '2,34', '0,4',
125 sellprice => [ 123.4, 2.34, 0.4 ],
127 }, 'arrays with filter';