Completed
Push — master ( 73da01...28cf8c )
by Wesley
04:37 queued 01:27
created

validationSubjectProvider()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 1
nop 0
dl 0
loc 15
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Wesnick\WorkflowBundle\Tests\Validation;
4
5
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
7
use Symfony\Component\Workflow\Tests\WorkflowBuilderTrait;
8
use Symfony\Component\Workflow\Transition;
9
use Symfony\Component\Workflow\Workflow;
10
use Wesnick\WorkflowBundle\Tests\Fixtures\ArticleWithWorkflow;
11
use Wesnick\WorkflowBundle\Validation\WorkflowValidationStrategy;
12
13
class WorkflowValidationStrategyTest extends TestCase
14
{
15
    use WorkflowBuilderTrait;
16
17
    /**
18
     * @dataProvider validationSubjectProvider
19
     */
20
    public function testGetValidationGroupsForSubject($subject, Workflow $workflow, Transition $transition, array $result)
21
    {
22
        $strategy = new WorkflowValidationStrategy();
23
        $groups = $strategy->getValidationGroupsForSubject($subject, $workflow, $transition);
24
        $this->assertEquals($result, $groups);
25
    }
26
27
    public function validationSubjectProvider()
28
    {
29
        $definition = $this->createComplexWorkflowDefinition();
30
        $transitions = $definition->getTransitions();
31
        $getTransitionByName = function ($name) use ($transitions) {
32
            foreach ($transitions as $transition) {
33
                if ($transition->getName() === $name) {
34
                    return $transition;
35
                }
36
            }
37
        };
38
        $workflow = new Workflow($definition, new MultipleStateMarkingStore());
39
40
        yield [new ArticleWithWorkflow(), $workflow, $getTransitionByName('t1'), ['Default', 'unnamed', 'unnamed_b', 'unnamed_c']];
41
        yield [new ArticleWithWorkflow(), $workflow, $getTransitionByName('t2'), ['Default', 'unnamed', 'unnamed_d']];
42
    }
43
}
44