Test Failed
Pull Request — master (#39)
by Roman
03:36
created

testCanBeConstructed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Kami\ApiCoreBundle\Tests\RequestProcessor\Step\Common;
4
5
use JMS\Serializer\Serializer;
6
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\SerializeResponseDataStep;
7
use Kami\Component\RequestProcessor\Artifact;
8
use Kami\Component\RequestProcessor\ArtifactCollection;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\HttpFoundation\Request;
11
12
class SerializeResponseDataStepTest extends TestCase
13
{
14
15
    public function testGetRequiredArtifacts()
16
    {
17
        $step = new SerializeResponseDataStep();
18
        $this->assertEquals(['serializer', 'response_data', 'access_granted'], $step->getRequiredArtifacts());
19
    }
20
21
    public function testExecute()
22
    {
23
        $serializerMock = $this->createMock(Serializer::class);
24
        $serializerMock->expects($this->any())->method('serialize')->willReturn([]);
25
26
        $step = new SerializeResponseDataStep();
27
28
        $step->setArtifacts(new ArtifactCollection([
29
            new Artifact('serializer', $serializerMock),
30
            new Artifact('response_data', [])
31
        ]));
32
33
        $response = $step->execute(new Request());
34
        $this->assertInstanceOf(ArtifactCollection::class, $response);
35
        $this->assertEquals([], $response->get('data')->getValue());
36
    }
37
}
38