Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ffddb5c0

Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt

  • ID ffddb5c07960091a33cfd6f91b6a3245efdcccf2
  • Vorgänger 78b23538
  • Nachfolger 471d166b

Tests für access-String-Auswertung des Menüs.

Unterschiede anzeigen:

t/menu/parse_access_string.t
1
use strict;
2

  
3
use Test::More;
4

  
5
use lib 't';
6
use Support::TestSetup;
7

  
8
Support::TestSetup::login();
9

  
10
use_ok 'SL::Menu';
11

  
12
#my $menu = SL::Menu->new('user');
13
my $menu = 'SL::Menu';
14

  
15
my %node;
16
$node{id} = 'test_node';
17

  
18
$node{access} = 'sales_quotation_edit';
19
ok($menu->parse_access_string(\%node), 'simple parse granted');
20

  
21
$node{access} = 'no such right';
22
ok(!$menu->parse_access_string(\%node), 'simple parse not granted');
23

  
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'); };
26

  
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'); };
29

  
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'); };
32

  
33
$node{access} = 'sales_order_edit & sales_quotation_edit';
34
ok($menu->parse_access_string(\%node), 'grant and grant');
35

  
36
$node{access} = 'no_such_right & sales_quotation_edit';
37
ok(!$menu->parse_access_string(\%node), 'not grant and grant');
38

  
39
$node{access} = 'no_such_right & no_such_right';
40
ok(!$menu->parse_access_string(\%node), 'not grant and not grant');
41

  
42
$node{access} = 'sales_order_edit|sales_quotation_edit';
43
ok($menu->parse_access_string(\%node), 'grant or grant');
44

  
45
$node{access} = 'no_such_right | sales_quotation_edit';
46
ok($menu->parse_access_string(\%node), 'not grant or grant');
47

  
48
$node{access} = 'no_such_right | no_such_right';
49
ok(!$menu->parse_access_string(\%node), 'not grant or not grant');
50

  
51
$node{access} = '(sales_quotation_edit & sales_order_edit | (no_such_right & sales_order_edit))';
52
ok($menu->parse_access_string(\%node), 'parenthesis 1');
53

  
54
$node{access} = '(no_such_right & sales_order_edit | (no_such_right & sales_order_edit))';
55
ok(!$menu->parse_access_string(\%node), 'parenthesis 2');
56

  
57
$node{access} = 'sales_quotation_edit & client/feature_experimental';
58
ok($menu->parse_access_string(\%node), 'client');
59

  
60
done_testing;
61

  
62
1;

Auch abrufbar als: Unified diff