Passed
Pull Request — master (#6)
by
unknown
02:45
created

ServiceFactoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 1

1 Method

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