Skip to content

Commit 83c73d0

Browse files
Merge branch '4.3' into 4.4
* 4.3: (23 commits) fix merge [SecurityBundle] fix return type declarations [BrowserKit] fix return type declarations [PropertyInfo] fix return type declarations [Bridge/Doctrine] fix return type declarations [Form] fix return type declarations [Console] fix return type declarations [Intl] fix return type declarations [Templating] fix return type declarations [DomCrawler] fix return type declarations [Validator] fix return type declarations [Process] fix return type declarations [Workflow] fix return type declarations [Cache] fix return type declarations [Serializer] fix return type declarations [Translation] fix return type declarations [DI] fix return type declarations [Config] fix return type declarations [HttpKernel] Fix return type declarations [Security] Fix return type declarations ...
2 parents 4607966 + 4848d38 commit 83c73d0

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

Tests/EventListener/GuardListenerTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
88
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
99
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
10+
use Symfony\Component\Security\Core\Role\RoleHierarchy;
11+
use Symfony\Component\Validator\ConstraintViolation;
12+
use Symfony\Component\Validator\ConstraintViolationList;
1013
use Symfony\Component\Validator\Validator\ValidatorInterface;
1114
use Symfony\Component\Workflow\Event\GuardEvent;
1215
use Symfony\Component\Workflow\EventListener\ExpressionLanguage;
@@ -41,7 +44,8 @@ protected function setUp(): void
4144
$this->authenticationChecker = $this->getMockBuilder(AuthorizationCheckerInterface::class)->getMock();
4245
$trustResolver = $this->getMockBuilder(AuthenticationTrustResolverInterface::class)->getMock();
4346
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
44-
$this->listener = new GuardListener($this->configuration, $expressionLanguage, $tokenStorage, $this->authenticationChecker, $trustResolver, null, $this->validator);
47+
$roleHierarchy = new RoleHierarchy([]);
48+
$this->listener = new GuardListener($this->configuration, $expressionLanguage, $tokenStorage, $this->authenticationChecker, $trustResolver, $roleHierarchy, $this->validator);
4549
}
4650

4751
protected function tearDown(): void
@@ -171,7 +175,7 @@ private function configureValidator($isUsed, $valid = true)
171175
$this->validator
172176
->expects($this->once())
173177
->method('validate')
174-
->willReturn($valid ? [] : ['a violation'])
178+
->willReturn(new ConstraintViolationList($valid ? [] : [new ConstraintViolation('a violation', null, [], '', null, '')]))
175179
;
176180
}
177181
}

Tests/WorkflowTest.php

+27-25
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Symfony\Component\Workflow\Marking;
1313
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
1414
use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore;
15-
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
1615
use Symfony\Component\Workflow\Transition;
1716
use Symfony\Component\Workflow\TransitionBlocker;
1817
use Symfony\Component\Workflow\Workflow;
@@ -21,6 +20,9 @@ class WorkflowTest extends TestCase
2120
{
2221
use WorkflowBuilderTrait;
2322

23+
/**
24+
* @group legacy
25+
*/
2426
public function testGetMarkingWithInvalidStoreReturn()
2527
{
2628
$this->expectException('Symfony\Component\Workflow\Exception\LogicException');
@@ -36,7 +38,7 @@ public function testGetMarkingWithEmptyDefinition()
3638
$this->expectException('Symfony\Component\Workflow\Exception\LogicException');
3739
$this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".');
3840
$subject = new Subject();
39-
$workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore());
41+
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
4042

4143
$workflow->getMarking($subject);
4244
}
@@ -47,7 +49,7 @@ public function testGetMarkingWithImpossiblePlace()
4749
$this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".');
4850
$subject = new Subject();
4951
$subject->setMarking(['nope' => 1]);
50-
$workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore());
52+
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
5153

5254
$workflow->getMarking($subject);
5355
}
@@ -56,7 +58,7 @@ public function testGetMarkingWithEmptyInitialMarking()
5658
{
5759
$definition = $this->createComplexWorkflowDefinition();
5860
$subject = new Subject();
59-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
61+
$workflow = new Workflow($definition, new MethodMarkingStore());
6062

6163
$marking = $workflow->getMarking($subject);
6264

@@ -70,7 +72,7 @@ public function testGetMarkingWithExistingMarking()
7072
$definition = $this->createComplexWorkflowDefinition();
7173
$subject = new Subject();
7274
$subject->setMarking(['b' => 1, 'c' => 1]);
73-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
75+
$workflow = new Workflow($definition, new MethodMarkingStore());
7476

7577
$marking = $workflow->getMarking($subject);
7678

@@ -83,7 +85,7 @@ public function testCanWithUnexistingTransition()
8385
{
8486
$definition = $this->createComplexWorkflowDefinition();
8587
$subject = new Subject();
86-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
88+
$workflow = new Workflow($definition, new MethodMarkingStore());
8789

8890
$this->assertFalse($workflow->can($subject, 'foobar'));
8991
}
@@ -92,7 +94,7 @@ public function testCan()
9294
{
9395
$definition = $this->createComplexWorkflowDefinition();
9496
$subject = new Subject();
95-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
97+
$workflow = new Workflow($definition, new MethodMarkingStore());
9698

9799
$this->assertTrue($workflow->can($subject, 't1'));
98100
$this->assertFalse($workflow->can($subject, 't2'));
@@ -123,7 +125,7 @@ public function testCanWithGuard()
123125
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
124126
$event->setBlocked(true);
125127
});
126-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
128+
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
127129

128130
$this->assertFalse($workflow->can($subject, 't1'));
129131
}
@@ -136,7 +138,7 @@ public function testCanDoesNotTriggerGuardEventsForNotEnabledTransitions()
136138
$dispatchedEvents = [];
137139
$eventDispatcher = new EventDispatcher();
138140

139-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
141+
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
140142
$workflow->apply($subject, 't1');
141143
$workflow->apply($subject, 't2');
142144

@@ -155,7 +157,7 @@ public function testCanDoesNotTriggerGuardEventsForNotEnabledTransitions()
155157
public function testCanWithSameNameTransition()
156158
{
157159
$definition = $this->createWorkflowWithSameNameTransition();
158-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
160+
$workflow = new Workflow($definition, new MethodMarkingStore());
159161

160162
$subject = new Subject();
161163
$this->assertTrue($workflow->can($subject, 'a_to_bc'));
@@ -183,7 +185,7 @@ public function testBuildTransitionBlockerList()
183185
{
184186
$definition = $this->createComplexWorkflowDefinition();
185187
$subject = new Subject();
186-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
188+
$workflow = new Workflow($definition, new MethodMarkingStore());
187189

188190
$this->assertTrue($workflow->buildTransitionBlockerList($subject, 't1')->isEmpty());
189191
$this->assertFalse($workflow->buildTransitionBlockerList($subject, 't2')->isEmpty());
@@ -208,7 +210,7 @@ public function testBuildTransitionBlockerListReturnsReasonsProvidedByMarking()
208210
{
209211
$definition = $this->createComplexWorkflowDefinition();
210212
$subject = new Subject();
211-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
213+
$workflow = new Workflow($definition, new MethodMarkingStore());
212214

213215
$transitionBlockerList = $workflow->buildTransitionBlockerList($subject, 't2');
214216
$this->assertCount(1, $transitionBlockerList);
@@ -222,7 +224,7 @@ public function testBuildTransitionBlockerListReturnsReasonsProvidedInGuards()
222224
$definition = $this->createSimpleWorkflowDefinition();
223225
$subject = new Subject();
224226
$dispatcher = new EventDispatcher();
225-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher);
227+
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher);
226228

227229
$dispatcher->addListener('workflow.guard', function (GuardEvent $event) {
228230
$event->addTransitionBlocker(new TransitionBlocker('Transition blocker 1', 'blocker_1'));
@@ -254,7 +256,7 @@ public function testApplyWithNotExisingTransition()
254256
$this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".');
255257
$definition = $this->createComplexWorkflowDefinition();
256258
$subject = new Subject();
257-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
259+
$workflow = new Workflow($definition, new MethodMarkingStore());
258260

259261
$workflow->apply($subject, '404 Not Found');
260262
}
@@ -263,7 +265,7 @@ public function testApplyWithNotEnabledTransition()
263265
{
264266
$definition = $this->createComplexWorkflowDefinition();
265267
$subject = new Subject();
266-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
268+
$workflow = new Workflow($definition, new MethodMarkingStore());
267269

268270
try {
269271
$workflow->apply($subject, 't2');
@@ -284,7 +286,7 @@ public function testApply()
284286
{
285287
$definition = $this->createComplexWorkflowDefinition();
286288
$subject = new Subject();
287-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
289+
$workflow = new Workflow($definition, new MethodMarkingStore());
288290

289291
$marking = $workflow->apply($subject, 't1');
290292

@@ -298,7 +300,7 @@ public function testApplyWithSameNameTransition()
298300
{
299301
$subject = new Subject();
300302
$definition = $this->createWorkflowWithSameNameTransition();
301-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
303+
$workflow = new Workflow($definition, new MethodMarkingStore());
302304

303305
$marking = $workflow->apply($subject, 'a_to_bc');
304306

@@ -336,7 +338,7 @@ public function testApplyWithSameNameTransition2()
336338
$transitions[] = new Transition('t', 'a', 'c');
337339
$transitions[] = new Transition('t', 'b', 'd');
338340
$definition = new Definition($places, $transitions);
339-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
341+
$workflow = new Workflow($definition, new MethodMarkingStore());
340342

341343
$marking = $workflow->apply($subject, 't');
342344

@@ -357,7 +359,7 @@ public function testApplyWithSameNameTransition3()
357359
$transitions[] = new Transition('t', 'b', 'c');
358360
$transitions[] = new Transition('t', 'c', 'd');
359361
$definition = new Definition($places, $transitions);
360-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
362+
$workflow = new Workflow($definition, new MethodMarkingStore());
361363

362364
$marking = $workflow->apply($subject, 't');
363365
// We want to make sure we do not end up in "d"
@@ -370,7 +372,7 @@ public function testApplyWithEventDispatcher()
370372
$definition = $this->createComplexWorkflowDefinition();
371373
$subject = new Subject();
372374
$eventDispatcher = new EventDispatcherMock();
373-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
375+
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
374376

375377
$eventNameExpected = [
376378
'workflow.entered',
@@ -417,7 +419,7 @@ public function testApplyDoesNotTriggerExtraGuardWithEventDispatcher()
417419

418420
$subject = new Subject();
419421
$eventDispatcher = new EventDispatcherMock();
420-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
422+
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
421423

422424
$eventNameExpected = [
423425
'workflow.entered',
@@ -470,7 +472,7 @@ public function testEventName()
470472
$subject = new Subject();
471473
$dispatcher = new EventDispatcher();
472474
$name = 'workflow_name';
473-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, $name);
475+
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, $name);
474476

475477
$assertWorkflowName = function (Event $event) use ($name) {
476478
$this->assertEquals($name, $event->getWorkflowName());
@@ -501,7 +503,7 @@ public function testMarkingStateOnApplyWithEventDispatcher()
501503

502504
$dispatcher = new EventDispatcher();
503505

504-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, 'test');
506+
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, 'test');
505507

506508
$assertInitialState = function (Event $event) {
507509
$this->assertEquals(new Marking(['a' => 1, 'b' => 1, 'c' => 1]), $event->getMarking());
@@ -535,7 +537,7 @@ public function testGetEnabledTransitions()
535537
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
536538
$event->setBlocked(true);
537539
});
538-
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
540+
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
539541

540542
$this->assertEmpty($workflow->getEnabledTransitions($subject));
541543

@@ -555,7 +557,7 @@ public function testGetEnabledTransitionsWithSameNameTransition()
555557
{
556558
$definition = $this->createWorkflowWithSameNameTransition();
557559
$subject = new Subject();
558-
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
560+
$workflow = new Workflow($definition, new MethodMarkingStore());
559561

560562
$transitions = $workflow->getEnabledTransitions($subject);
561563
$this->assertCount(1, $transitions);

0 commit comments

Comments
 (0)