ViafCannedResponseParserTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testParser() 0 36 1
B fileProvider() 0 32 1
1
<?php
2
3
namespace Onoi\Remi\Tests\Integration\Viaf;
4
5
use Onoi\Remi\FilteredHttpResponseParserFactory;
6
use Onoi\Remi\FilteredRecord;
7
8
/**
9
 * @group semantic-cite
10
 *
11
 * @license GNU GPL v2+
12
 * @since 0.1
13
 *
14
 * @author mwjames
15
 */
16
class ViafCannedResponseParserTest extends \PHPUnit_Framework_TestCase {
17
18
	/**
19
	 * @dataProvider fileProvider
20
	 */
21
	public function testParser( $id, $httpRequestFile, $expectedResultFile ) {
22
23
		$contents = file_get_contents( $httpRequestFile );
24
25
		$httpRequest = $this->getMockBuilder( '\Onoi\HttpRequest\HttpRequest' )
26
			->disableOriginalConstructor()
27
			->getMock();
28
29
		$httpRequest->expects( $this->any() )
30
			->method( 'execute' )
31
			->will( $this->returnValue( $contents ) );
32
33
		$httpRequest->expects( $this->any() )
34
			->method( 'getLastError' )
35
			->will( $this->returnValue( '' ) );
36
37
		$filteredHttpResponseParserFactory = new FilteredHttpResponseParserFactory(
38
			$httpRequest
39
		);
40
41
		$instance = $filteredHttpResponseParserFactory->newViafFilteredHttpResponseParser(
42
			new FilteredRecord()
43
		);
44
45
		$this->assertEquals(
46
			$contents,
47
			$instance->getRawResponseById( $id )
0 ignored issues
show
Bug introduced by
The method getRawResponseById() does not exist on Onoi\Remi\ResponseParser. Did you maybe mean getRawResponse()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
48
		);
49
50
		$instance->doFilterResponseById( $id );
51
52
		$this->assertJsonStringEqualsJsonFile(
53
			$expectedResultFile,
54
			$instance->getFilteredRecord()->asJsonString()
55
		);
56
	}
57
58
	public function fileProvider() {
59
60
		$path = __DIR__ . '/Fixtures/';
61
		$provider = array();
62
63
		$provider[] = array(
64
			'253484422',
65
			$path . '253484422.xml',
66
			$path . '253484422.expected'
67
		);
68
69
		$provider[] = array(
70
			'50566653',
71
			$path . '50566653.xml',
72
			$path . '50566653.expected'
73
		);
74
75
		$provider[] = array(
76
			'99929837',
77
			$path . '99929837.xml',
78
			$path . '99929837.expected'
79
		);
80
81
		// Corporate
82
		$provider[] = array(
83
			'138978451',
84
			$path . '138978451.xml',
85
			$path . '138978451.expected'
86
		);
87
88
		return $provider;
89
	}
90
91
}
92