@@ -123,7 +123,7 @@ public function testConfigureSideMenuWithoutWorkflow()
123
123
/**
124
124
* @dataProvider markingToTransition
125
125
*/
126
- public function testConfigureSideMenu ($ marking , array $ transitions )
126
+ public function testConfigureSideMenu ($ marking , array $ transitions, $ grantedApply )
127
127
{
128
128
$ pullRequest = new PullRequest ();
129
129
$ pullRequest ->setMarking ($ marking );
@@ -137,14 +137,24 @@ public function testConfigureSideMenu($marking, array $transitions)
137
137
$ admin ->getLabelTranslatorStrategy ()->willReturn ($ labelStrategy ->reveal ());
138
138
$ admin ->getSubject ()->willReturn ($ pullRequest );
139
139
$ admin ->checkAccess ('viewTransitions ' , $ pullRequest )->shouldBeCalled ();
140
+ if ($ grantedApply ) {
141
+ $ admin ->checkAccess ('applyTransitions ' , $ pullRequest )->shouldBeCalledTimes (count ($ transitions ));
142
+ } else {
143
+ $ admin ->checkAccess ('applyTransitions ' , $ pullRequest )->willThrow (new AccessDeniedException ());
144
+ }
140
145
141
146
foreach ($ transitions as $ transition ) {
142
147
$ labelStrategy ->getLabel ($ transition , 'workflow ' , 'transition ' )
143
148
->shouldBeCalledTimes (1 )
144
149
->willReturn ('workflow.transition. ' .$ transition );
145
- $ admin ->generateObjectUrl ('workflow_apply_transition ' , $ pullRequest , ['transition ' => $ transition ])
146
- ->shouldBeCalledTimes (1 )
147
- ->willReturn ('/pull-request/42/workflow/transition/ ' .$ transition .'/apply ' );
150
+ if ($ grantedApply ) {
151
+ $ admin ->generateObjectUrl ('workflow_apply_transition ' , $ pullRequest , ['transition ' => $ transition ])
152
+ ->shouldBeCalledTimes (1 )
153
+ ->willReturn ('/pull-request/42/workflow/transition/ ' .$ transition .'/apply ' );
154
+ } else {
155
+ $ admin ->generateObjectUrl ('workflow_apply_transition ' , $ pullRequest , ['transition ' => $ transition ])
156
+ ->shouldNotBeCalled ();
157
+ }
148
158
}
149
159
150
160
$ registry = new Registry ();
@@ -182,7 +192,11 @@ public function testConfigureSideMenu($marking, array $transitions)
182
192
}
183
193
184
194
self ::assertNotNull ($ item = $ child ->getChild ('workflow.transition. ' .$ transition ));
185
- self ::assertSame ('/pull-request/42/workflow/transition/ ' .$ transition .'/apply ' , $ item ->getUri ());
195
+ if ($ grantedApply ) {
196
+ self ::assertSame ('/pull-request/42/workflow/transition/ ' .$ transition .'/apply ' , $ item ->getUri ());
197
+ } else {
198
+ self ::assertNull ($ item ->getUri ());
199
+ }
186
200
self ::assertSame ('admin ' , $ item ->getExtra ('translation_domain ' ));
187
201
self ::assertSame ($ icon , $ item ->getAttribute ('icon ' ));
188
202
}
@@ -191,10 +205,12 @@ public function testConfigureSideMenu($marking, array $transitions)
191
205
192
206
public function markingToTransition ()
193
207
{
194
- return [
195
- 'opened ' => ['opened ' , ['start_review ' ]],
196
- 'pending_review ' => ['pending_review ' , ['merge ' , 'close ' ]],
197
- 'closed ' => ['closed ' , []],
198
- ];
208
+ foreach ([true , false ] as $ grantedApply ) {
209
+ $ grantedApplyStr = $ grantedApply ? 'with links ' : 'without links ' ;
210
+
211
+ yield 'opened ' .$ grantedApplyStr => ['opened ' , ['start_review ' ], $ grantedApply ];
212
+ yield 'pending_review ' .$ grantedApplyStr => ['pending_review ' , ['merge ' , 'close ' ], $ grantedApply ];
213
+ yield 'closed ' .$ grantedApplyStr => ['closed ' , [], $ grantedApply ];
214
+ }
199
215
}
200
216
}
0 commit comments