testGetValidationGroupsForSubject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 4
dl 0
loc 5
rs 10
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;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Workfl...ts\WorkflowBuilderTrait 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...
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());
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\Workfl...ltipleStateMarkingStore has been deprecated: since Symfony 4.3, use MethodMarkingStore instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

38
        $workflow = new Workflow($definition, /** @scrutinizer ignore-deprecated */ new MultipleStateMarkingStore());
Loading history...
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