Completed
Pull Request — master (#433)
by Albin
10:58
created

LocalStreamSpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_throws_runtime_exception_when_file_doesnt_exists() 0 5 1
A it_throws_runtime_exception_when_file_doesnt_exists_and_custom_error_handler_specified() 0 12 1
1
<?php
2
3
namespace spec\Gaufrette\Adapter\Local;
4
5
use PhpSpec\ObjectBehavior;
6
use Gaufrette\StreamMode;
7
use org\bovigo\vfs\vfsStream;
8
9
class LocalStreamSpec extends ObjectBehavior
10
{
11
    function it_throws_runtime_exception_when_file_doesnt_exists()
12
    {
13
        $this->beConstructedWith(vfsStream::url('other'));
14
        $this->shouldThrow('\RuntimeException')->duringOpen(new StreamMode('r'));
15
    }
16
17
    function it_throws_runtime_exception_when_file_doesnt_exists_and_custom_error_handler_specified()
18
    {
19
        $custom_error_handler = function ($errno, $errstr, $errfile, $errline) {
20
            throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
21
        };
22
        set_error_handler($custom_error_handler);
23
24
        $this->beConstructedWith(vfsStream::url('other'));
25
        $this->shouldThrow('\RuntimeException')->duringOpen(new StreamMode('r'));
26
27
        restore_error_handler();
28
    }
29
}
30