Completed
Pull Request — master (#9)
by Hugo
01:41
created

UploadFileSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace spec\Yproximite\Api\Util;
4
5
use PhpSpec\ObjectBehavior;
6
use Yproximite\Api\Exception\FileNotFoundException;
7
use Yproximite\Api\Util\UploadFile;
8
9
class UploadFileSpec extends ObjectBehavior
10
{
11
    public function it_is_initializable()
12
    {
13
        $this->beConstructedWith('foo');
14
        $this->shouldHaveType(UploadFile::class);
15
    }
16
17
    public function it_should_works_if_file_is_a_string()
18
    {
19
        $this->beConstructedWith(__DIR__.'/../fixtures/Yproximite.png');
20
21
        $this->getName()->shouldReturn('Yproximite.png');
22
        $this->getPath()->shouldReturn(__DIR__.'/../fixtures/Yproximite.png');
23
        $this->getContent()->shouldBeString();
24
    }
25
26 View Code Duplication
    public function it_should_works_if_file_is_an_array_but_without_filename()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $this->beConstructedWith(['path' => __DIR__.'/../fixtures/Yproximite.png']);
29
30
        $this->getName()->shouldReturn('Yproximite.png');
31
        $this->getPath()->shouldReturn(__DIR__.'/../fixtures/Yproximite.png');
32
        $this->getContent()->shouldBeString();
33
    }
34
35 View Code Duplication
    public function it_should_works_if_file_is_an_array()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $this->beConstructedWith(['path' => __DIR__.'/../fixtures/Yproximite.png', 'name' => 'Filename.png']);
38
39
        $this->getName()->shouldReturn('Filename.png');
40
        $this->getPath()->shouldReturn(__DIR__.'/../fixtures/Yproximite.png');
41
        $this->getContent()->shouldBeString();
42
    }
43
44
    public function it_should_fails_if_file_do_not_exists()
45
    {
46
        $this->beConstructedWith('file-that-do-not-exists.png');
47
        $this->shouldThrow(FileNotFoundException::class)->duringInstantiation();
48
    }
49
}
50