Completed
Push — 2.0 ( 60b181...751b46 )
by Nicolas
03:03
created

MediaPathTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 43
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_can_instantiate_value_object() 0 6 1
A it_only_acepts_a_string_as_argument() 0 6 1
A it_can_get_the_url() 0 6 1
A it_can_get_the_relative_url() 0 6 1
A it_casts_media_path_to_string_using_url_method() 0 7 1
1
<?php
2
3
namespace Modules\Media\Tests;
4
5
use Modules\Media\ValueObjects\MediaPath;
6
7
class MediaPathTest extends \PHPUnit_Framework_TestCase
8
{
9
    /** @test */
10
    public function it_can_instantiate_value_object()
11
    {
12
        $path = new MediaPath('some/path.jpg');
13
14
        $this->assertInstanceOf(MediaPath::class, $path);
15
    }
16
17
    /** @test */
18
    public function it_only_acepts_a_string_as_argument()
19
    {
20
        $this->setExpectedException(\InvalidArgumentException::class);
21
22
        new MediaPath(['something']);
23
    }
24
25
    /** @test */
26
    public function it_can_get_the_url()
27
    {
28
        $path = new MediaPath('some/path.jpg');
29
30
        $this->assertEquals('http://localhost/some/path.jpg', $path->getUrl());
31
    }
32
33
    /** @test */
34
    public function it_can_get_the_relative_url()
35
    {
36
        $path = new MediaPath('some/path.jpg');
37
38
        $this->assertEquals('some/path.jpg', $path->getRelativeUrl());
39
    }
40
41
    /** @test */
42
    public function it_casts_media_path_to_string_using_url_method()
43
    {
44
        $path = new MediaPath('some/path.jpg');
45
46
        $this->assertEquals('http://localhost/some/path.jpg', (string) $path);
47
        $this->assertNotEquals('some/path.jpg', (string) $path);
48
    }
49
}
50