ServiceFactoryTest::itShouldReturnAService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 26
nc 1
nop 0
dl 0
loc 37
rs 9.504
c 0
b 0
f 0
1
<?php
2
namespace ElevenLabs\ApiServiceBundle\Factory;
3
4
use ElevenLabs\Api\Decoder\DecoderInterface;
5
use ElevenLabs\Api\Factory\SchemaFactory;
6
use ElevenLabs\Api\Schema;
7
use ElevenLabs\Api\Service\ApiService;
8
use Http\Client\HttpClient;
9
use Http\Message\MessageFactory;
10
use Http\Message\UriFactory;
11
use JsonSchema\Validator;
12
use PHPUnit\Framework\TestCase;
13
use org\bovigo\vfs\vfsStream;
0 ignored issues
show
Bug introduced by
The type org\bovigo\vfs\vfsStream 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...
14
use Rize\UriTemplate;
15
use Symfony\Component\Serializer\SerializerInterface;
16
17
class ServiceFactoryTest extends TestCase
18
{
19
    /** @test */
20
    public function itShouldReturnAService()
21
    {
22
        $aSchemaFile = 'schema.json';
23
24
        $uriFactory = $this->prophesize(UriFactory::class);
25
        $uriTemplate = $this->prophesize(UriTemplate::class);
26
        $messageFactory = $this->prophesize(MessageFactory::class);
27
        $validator = $this->prophesize(Validator::class);
28
        $serializer = $this->prophesize(SerializerInterface::class);
29
        $decoder = $this->prophesize(DecoderInterface::class);
30
31
        $factory = new ServiceFactory(
32
            $uriFactory->reveal(),
33
            $uriTemplate->reveal(),
34
            $messageFactory->reveal(),
35
            $validator->reveal(),
36
            $serializer->reveal(),
37
            $decoder->reveal()
38
        );
39
40
        $httpClient = $this->prophesize(HttpClient::class);
41
42
        $schema = $this->prophesize(Schema::class);
43
        $schema->getSchemes()->willReturn(['http']);
44
        $schema->getHost()->willReturn('domain.tld');
45
46
        $schemaFactory = $this->prophesize(SchemaFactory::class);
47
        $schemaFactory->createSchema($aSchemaFile)->shouldBeCalledTimes(1)->willReturn($schema);
48
49
        $service = $factory->getService(
50
            $httpClient->reveal(),
51
            $schemaFactory->reveal(),
52
            $aSchemaFile,
53
            $config = []
54
        );
55
56
        self::assertInstanceOf(ApiService::class, $service);
57
    }
58
}
59