Completed
Pull Request — master (#36)
by Roman
04:41
created

ValidateFormStepTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Kami\ApiCoreBundle\Tests\RequestProcessor\Step\Common;
4
5
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\HandleRequestStep;
6
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\ValidateFormStep;
7
use Kami\Component\RequestProcessor\Artifact;
8
use Kami\Component\RequestProcessor\ArtifactCollection;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Form\Form;
11
use Symfony\Component\HttpFoundation\Request;
12
use Kami\ApiCoreBundle\RequestProcessor\ProcessorResponse;
0 ignored issues
show
Bug introduced by
The type Kami\ApiCoreBundle\Reque...essor\ProcessorResponse 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...
13
14
class ValidateFormStepTest extends TestCase
15
{
16
17
    public function testExecute()
18
    {
19
        $step = new ValidateFormStep();
20
21
        $formMock = $this->createMock(Form::class);
22
        $formMock->method('isValid')->willReturn(true);
0 ignored issues
show
Bug introduced by
The method method() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

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

22
        $formMock->/** @scrutinizer ignore-call */ 
23
                   method('isValid')->willReturn(true);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
        $step->setArtifacts(new ArtifactCollection([
24
            new Artifact('form', $formMock)
25
        ]));
26
27
        $artifacts = $step->execute(new Request());
28
29
        $this->assertInstanceOf(ArtifactCollection::class, $artifacts);
30
        $this->assertTrue(true, $artifacts->get('validation'));
31
    }
32
33
    public function testGetRequiredArtifacts()
34
    {
35
        $step = new ValidateFormStep();
36
37
        $this->assertEquals(['handled_request', 'access_granted', 'form'], $step->getRequiredArtifacts());
38
    }
39
}
40