Completed
Push — master ( 1a30e2...818da8 )
by Jeroen De
03:02
created

InMemoryFileFetcherTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testWhenEmptyHash_requestsCauseException() 0 6 1
A testWhenUrlNotKnown_requestsCauseException() 0 8 1
A testWhenUrlKnown_requestsReturnsValue() 0 8 1
1
<?php
2
3
namespace FileFetcher\Tests\Phpunit;
4
5
use FileFetcher\InMemoryFileFetcher;
6
7
/**
8
 * @covers FileFetcher\InMemoryFileFetcher
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class InMemoryFileFetcherTest extends \PHPUnit_Framework_TestCase {
14
15
	public function testWhenEmptyHash_requestsCauseException() {
16
		$fetcher = new InMemoryFileFetcher( array() );
17
18
		$this->setExpectedException( 'FileFetcher\FileFetchingException' );
19
		$fetcher->fetchFile( 'http://foo.bar/baz' );
20
	}
21
22
	public function testWhenUrlNotKnown_requestsCauseException() {
23
		$fetcher = new InMemoryFileFetcher( array(
24
			'http://something.else/entirely' => 'kittens'
25
		) );
26
27
		$this->setExpectedException( 'FileFetcher\FileFetchingException' );
28
		$fetcher->fetchFile( 'http://foo.bar/baz' );
29
	}
30
31
	public function testWhenUrlKnown_requestsReturnsValue() {
32
		$fetcher = new InMemoryFileFetcher( array(
33
			'http://something.else/entirely' => 'kittens',
34
			'http://foo.bar/baz' => 'cats'
35
		) );
36
37
		$this->assertSame( 'cats', $fetcher->fetchFile( 'http://foo.bar/baz' ) );
38
	}
39
40
}
41