Completed
Push — master ( 144614...3a2d63 )
by Albin
13s
created

AwsS3PresignedUrlResolverSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 29
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_is_a_resolver() 0 4 1
A it_resolves_object_path_into_presigned_url() 0 11 1
1
<?php
2
3
namespace spec\Gaufrette\Extras\Resolvable\Resolver;
4
5
use Aws\CommandInterface;
6
use Aws\S3\S3Client;
7
use Gaufrette\Extras\Resolvable\Resolver\AwsS3PresignedUrlResolver;
8
use Gaufrette\Extras\Resolvable\ResolverInterface;
9
use PhpSpec\ObjectBehavior;
10
use Prophecy\Argument;
11
use Psr\Http\Message\RequestInterface;
12
13
class AwsS3PresignedUrlResolverSpec extends ObjectBehavior
14
{
15
    function let(S3Client $client)
16
    {
17
        $this->beConstructedWith($client, 'bucket', '/base/dir/', new \DateTime('+12 hour'));
18
    }
19
20
    function it_is_initializable()
21
    {
22
        $this->shouldHaveType(AwsS3PresignedUrlResolver::class);
23
    }
24
25
    function it_is_a_resolver()
26
    {
27
        $this->shouldImplement(ResolverInterface::class);
28
    }
29
30
    function it_resolves_object_path_into_presigned_url(
31
        $client,
32
        CommandInterface $command,
33
        RequestInterface $presignedRequest
34
    ) {
35
        $client->getCommand('GetObject', ['Bucket' => 'bucket', 'Key' => 'base/dir/foo.png'])->willReturn($command);
36
        $client->createPresignedRequest($command, Argument::type(\DateTime::class))->willReturn($presignedRequest);
37
        $presignedRequest->getUri()->willReturn('https://amazon');
38
39
        $this->resolve('/foo.png')->shouldReturn('https://amazon');
40
    }
41
}
42