X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=t%2Fcontrollers%2Fhelpers%2Fparse_filter.t;h=c72c33fce83ebb89487f7cbed6cb8f8c2b540359;hb=c6b2257945060625bcb86fa7e2efd27c737480ff;hp=554985d92604407c5791060f5a3702a9f9cd9d61;hpb=39556a0d83b35291fec9a17cd14762232ae008d7;p=kivitendo-erp.git diff --git a/t/controllers/helpers/parse_filter.t b/t/controllers/helpers/parse_filter.t index 554985d92..c72c33fce 100644 --- a/t/controllers/helpers/parse_filter.t +++ b/t/controllers/helpers/parse_filter.t @@ -1,12 +1,14 @@ use lib 't'; -use Test::More tests => 17; +use Test::More tests => 23; use Test::Deep; use Data::Dumper; use_ok 'Support::TestSetup'; use_ok 'SL::Controller::Helper::ParseFilter'; +use SL::DB::OrderItem; + undef *::any; # Test::Deep exports any (for junctions) and MoreCommon exports any (like in List::Moreutils) Support::TestSetup::login(); @@ -35,10 +37,10 @@ test { name => 'Test', whut => 'moof', }, { - query => [ %{{ + query => bag( name => 'Test', whut => 'moof' - }} ], + ), }, 'basic test'; test { @@ -96,10 +98,10 @@ test { }, }, }, { - 'query' => [ %{{ + 'query' => bag( 'invoice.customer.name' => 'test', 'customer.name' => 'test', - }} ], + ), 'with_objects' => bag( 'invoice.customer', 'customer', 'invoice' ) }, 'object in more than one relationship'; @@ -140,7 +142,7 @@ test { ] }, { 'sellprice:number' => [ '123,4', '2,34', '0,4' ], - 'sellprice_number' => [ '123,4', '2,34', '0,4' ], + 'sellprice_number_' => { '123,4' => 1, '2,34' => 1, '0,4' => 1 }, }, 'laundering with array', target => 'filter'; my %args = ( @@ -190,3 +192,58 @@ test { with_objects => bag('order.customer', 'order'), }, 'sub objects have to retain their prefix'; +### class filter dispatch +# +test { + name => 'Test', + whut => 'moof', +}, { + query => bag( + name => 'Test', + whut => 'moof' + ), +}, 'object test simple', class => 'SL::DB::Manager::Part'; + +test { + 'type' => 'assembly', +}, { + query => [ + 'assembly' => 1 + ], +}, 'object test without prefix', class => 'SL::DB::Manager::Part'; + +test { + 'part.type' => 'assembly', +}, { + query => [ + 'part.assembly' => 1 + ], +}, 'object test with prefix', class => 'SL::DB::Manager::OrderItem'; + +test { + 'type' => [ 'part', 'assembly' ], +}, { + query => [ + or => [ + and => [ or => [ assembly => 0, assembly => undef ], + "!inventory_accno_id" => 0, + "!inventory_accno_id" => undef, + ], + assembly => 1, + ] + ], +}, 'object test without prefix but complex value', class => 'SL::DB::Manager::Part'; + +test { + 'part.type' => [ 'part', 'assembly' ], +}, { + query => [ + or => [ + and => [ or => [ 'part.assembly' => 0, 'part.assembly' => undef ], + "!part.inventory_accno_id" => 0, + "!part.inventory_accno_id" => undef, + ], + 'part.assembly' => 1, + ] + ], +}, 'object test with prefix but complex value', class => 'SL::DB::Manager::OrderItem';