6 use Support::TestSetup;
8 Support::TestSetup::login();
12 #my $menu = SL::Menu->new('user');
13 my $menu = 'SL::Menu';
16 $node{id} = 'test_node';
18 $node{access} = 'sales_quotation_edit';
19 ok($menu->parse_access_string(\%node), 'simple parse granted');
21 $node{access} = 'no such right';
22 ok(!$menu->parse_access_string(\%node), 'simple parse not granted');
24 $node{access} = 'sales_quotation_edit)';
25 eval {$menu->parse_access_string(\%node); ok(0, 'detect missing opening parenthesis'); 1} or do { ok(1, 'detect missing opening parenthesis'); };
27 $node{access} = '(sales_quotation_edit';
28 eval {$menu->parse_access_string(\%node); ok(0, 'detect missing closing parenthesis'); 1} or do { ok(1, 'detect missing closing parenthesis'); };
30 $node{access} = 'sales_quotation_edit-';
31 eval {$menu->parse_access_string(\%node); ok(0, 'detect unrecognized token'); 1} or do { ok(1, 'detect unrecognized token'); };
33 $node{access} = 'sales_order_edit & sales_quotation_edit';
34 ok($menu->parse_access_string(\%node), 'grant and grant');
36 $node{access} = 'no_such_right & sales_quotation_edit';
37 ok(!$menu->parse_access_string(\%node), 'not grant and grant');
39 $node{access} = 'no_such_right & no_such_right';
40 ok(!$menu->parse_access_string(\%node), 'not grant and not grant');
42 $node{access} = 'sales_order_edit|sales_quotation_edit';
43 ok($menu->parse_access_string(\%node), 'grant or grant');
45 $node{access} = 'no_such_right | sales_quotation_edit';
46 ok($menu->parse_access_string(\%node), 'not grant or grant');
48 $node{access} = 'no_such_right | no_such_right';
49 ok(!$menu->parse_access_string(\%node), 'not grant or not grant');
51 $node{access} = '(sales_quotation_edit & sales_order_edit | (no_such_right & sales_order_edit))';
52 ok($menu->parse_access_string(\%node), 'parenthesis 1');
54 $node{access} = '(no_such_right & sales_order_edit | (no_such_right & sales_order_edit))';
55 ok(!$menu->parse_access_string(\%node), 'parenthesis 2');
57 $node{access} = 'sales_quotation_edit & client/feature_experimental_order';
58 ok($menu->parse_access_string(\%node), 'client');
60 $node{access} = '!no_such_right';
61 ok($menu->parse_access_string(\%node), 'simple negation 1');
63 $node{access} = '!sales_order_edit';
64 ok(!$menu->parse_access_string(\%node), 'simple negation 2');
66 $node{access} = '!!sales_order_edit';
67 ok($menu->parse_access_string(\%node), 'double negation');
69 $node{access} = '(no_such_right & sales_order_edit | !(no_such_right & sales_order_edit))';
70 ok($menu->parse_access_string(\%node), 'parenthesis with negation 1');
72 $node{access} = '(no_such_right & sales_order_edit | (!no_such_right | !sales_order_edit))';
73 ok($menu->parse_access_string(\%node), 'parenthesis with negation 2');
75 $node{access} = 'sales_quotation_edit & !client/feature_experimental_order';
76 ok(!$menu->parse_access_string(\%node), 'client negation');