@@ -22,60 +22,81 @@ public function test_display_autogroups()
2222
2323 // Mocked manager should output the expected values
2424 // from get_condition_lang() at the expected times.
25+ $ manager_expectations = [
26+ ['phpbb.autogroups.type.sample1 ' , 'phpbb.autogroups.type.sample1 ' ],
27+ ['phpbb.autogroups.type.sample2 ' , 'phpbb.autogroups.type.sample2 ' ]
28+ ];
2529 $ this ->manager ->expects (self ::exactly (2 ))
2630 ->method ('get_condition_lang ' )
27- ->withConsecutive (['phpbb.autogroups.type.sample1 ' ], ['phpbb.autogroups.type.sample2 ' ])
28- ->willReturnOnConsecutiveCalls ('phpbb.autogroups.type.sample1 ' , 'phpbb.autogroups.type.sample2 ' );
31+ ->willReturnCallback (function ($ arg ) use (&$ manager_expectations ) {
32+ $ expectation = array_shift ($ manager_expectations );
33+ self ::assertEquals ($ expectation [0 ], $ arg );
34+ return $ expectation [1 ];
35+ });
2936
3037 // Set expectations for the assign_block_vars template values
38+ $ template_invocation = 0 ;
3139 $ this ->template ->expects (self ::exactly (4 ))
3240 ->method ('assign_block_vars ' )
33- ->withConsecutive (
34- array ('autogroups ' , array (
35- 'GROUP_NAME ' => 'GROUP1 ' ,
36- 'CONDITION_NAME ' => 'phpbb.autogroups.type.sample1 ' ,
37- 'MIN_VALUE ' => 0 ,
38- 'MAX_VALUE ' => 20 ,
39- 'S_DEFAULT ' => 1 ,
40- 'S_NOTIFY ' => 0 ,
41- 'EXCLUDED_GROUPS ' => '' ,
42- 'U_EDIT ' => 'index.php&action=edit&autogroups_id=1 ' ,
43- 'U_DELETE ' => 'index.php&action=delete&autogroups_id=1 ' ,
44- 'U_SYNC ' => 'index.php&action=sync&autogroups_id=1&hash= ' . generate_link_hash ('sync ' . 1 ),
45- )),
46- array ('autogroups ' , array (
47- 'GROUP_NAME ' => 'GROUP2 ' ,
48- 'CONDITION_NAME ' => 'phpbb.autogroups.type.sample2 ' ,
49- 'MIN_VALUE ' => 30 ,
50- 'MAX_VALUE ' => 50 ,
51- 'S_DEFAULT ' => 0 ,
52- 'S_NOTIFY ' => 0 ,
53- 'EXCLUDED_GROUPS ' => '' ,
54- 'U_EDIT ' => 'index.php&action=edit&autogroups_id=2 ' ,
55- 'U_DELETE ' => 'index.php&action=delete&autogroups_id=2 ' ,
56- 'U_SYNC ' => 'index.php&action=sync&autogroups_id=2&hash= ' . generate_link_hash ('sync ' . 2 ),
57- )),
58- array ('groups ' , array (
59- 'GROUP_ID ' => 1 ,
60- 'GROUP_NAME ' => 'GROUP1 ' ,
61- 'S_SELECTED ' => false ,
62- )),
63- array ('groups ' , array (
64- 'GROUP_ID ' => 2 ,
65- 'GROUP_NAME ' => 'GROUP2 ' ,
66- 'S_SELECTED ' => true ,
67- ))
68- )
69- ;
41+ ->willReturnCallback (function ($ block , $ vars ) use (&$ template_invocation ) {
42+ switch ($ template_invocation ) {
43+ case 0 :
44+ self ::assertEquals ('autogroups ' , $ block );
45+ self ::assertEquals (array (
46+ 'GROUP_NAME ' => 'GROUP1 ' ,
47+ 'CONDITION_NAME ' => 'phpbb.autogroups.type.sample1 ' ,
48+ 'MIN_VALUE ' => '0 ' ,
49+ 'MAX_VALUE ' => '20 ' ,
50+ 'S_DEFAULT ' => '1 ' ,
51+ 'S_NOTIFY ' => '0 ' ,
52+ 'EXCLUDED_GROUPS ' => '' ,
53+ 'U_EDIT ' => 'index.php&action=edit&autogroups_id=1 ' ,
54+ 'U_DELETE ' => 'index.php&action=delete&autogroups_id=1 ' ,
55+ 'U_SYNC ' => 'index.php&action=sync&autogroups_id=1&hash= ' . generate_link_hash ('sync ' . 1 ),
56+ ), $ vars );
57+ break ;
58+ case 1 :
59+ self ::assertEquals ('autogroups ' , $ block );
60+ self ::assertEquals (array (
61+ 'GROUP_NAME ' => 'GROUP2 ' ,
62+ 'CONDITION_NAME ' => 'phpbb.autogroups.type.sample2 ' ,
63+ 'MIN_VALUE ' => '30 ' ,
64+ 'MAX_VALUE ' => '50 ' ,
65+ 'S_DEFAULT ' => '0 ' ,
66+ 'S_NOTIFY ' => '0 ' ,
67+ 'EXCLUDED_GROUPS ' => '' ,
68+ 'U_EDIT ' => 'index.php&action=edit&autogroups_id=2 ' ,
69+ 'U_DELETE ' => 'index.php&action=delete&autogroups_id=2 ' ,
70+ 'U_SYNC ' => 'index.php&action=sync&autogroups_id=2&hash= ' . generate_link_hash ('sync ' . 2 ),
71+ ), $ vars );
72+ break ;
73+ case 2 :
74+ self ::assertEquals ('groups ' , $ block );
75+ self ::assertEquals (array (
76+ 'GROUP_ID ' => 1 ,
77+ 'GROUP_NAME ' => 'GROUP1 ' ,
78+ 'S_SELECTED ' => false ,
79+ ), $ vars );
80+ break ;
81+ case 3 :
82+ self ::assertEquals ('groups ' , $ block );
83+ self ::assertEquals (array (
84+ 'GROUP_ID ' => 2 ,
85+ 'GROUP_NAME ' => 'GROUP2 ' ,
86+ 'S_SELECTED ' => true ,
87+ ), $ vars );
88+ break ;
89+ }
90+ $ template_invocation ++;
91+ });
7092
7193 // Set expectations for the assign_vars template values
7294 $ this ->template ->expects (self ::once ())
7395 ->method ('assign_vars ' )
7496 ->with (array (
7597 'U_ACTION ' => 'index.php ' ,
7698 'U_ADD_AUTOGROUP_RULE ' => 'index.php&action=add ' ,
77- ))
78- ;
99+ ));
79100
80101 // Set a u_index test value
81102 $ this ->admin_controller ->set_page_url ('index.php ' );
0 commit comments