Passed
Push — main ( 6731d6...4efee0 )
by Dan Michael O.
11:38
created

ExplainResponseTest::testNormalResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 110
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 1
eloc 13
c 2
b 1
f 1
nc 1
nop 0
dl 0
loc 110
rs 9.8333

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace Scriptotek\Sru;
2
3
use Mockery as m;
0 ignored issues
show
Bug introduced by
The type Mockery was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
5
class ExplainResponseTest extends TestCase
6
{
7
    public function testNormalResponse()
8
    {
9
        $res = new ExplainResponse('<?xml version="1.0" encoding="UTF-8"?>
10
			<sru:explainResponse xmlns:sru="http://www.loc.gov/zing/srw/">
11
			  <sru:version>1.2</sru:version>
12
			  <sru:record>
13
			    <sru:recordPacking>xml</sru:recordPacking>
14
			    <sru:recordSchema>http://explain.z3950.org/dtd/2.0/</sru:recordSchema>
15
			    <sru:recordData>
16
			      <explain xmlns="http://explain.z3950.org/dtd/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://explain.z3950.org/dtd/2.0/ http://explain.z3950.org/dtd/zeerex-2.0.xsd">
17
			        <serverInfo protocol="SRU" transport="http">
18
			          <host>sru.bibsys.no</host>
19
			          <port>80</port>
20
			          <database>biblio</database>
21
			        </serverInfo>
22
			        <databaseInfo>
23
			          <title lang="en" primary="true">BIBSYS Union Catalogue</title>
24
			          <description lang="en">SRU access to the BIBSYS Union Catalogue.</description>
25
			          <contact lang="en">[email protected]</contact>
26
			          <restrictions lang="en">It is prohibited to use this service for bulk downloading of records.</restrictions>
27
			          <links>
28
			            <link type="icon">http://www.bibsys.no/images/logo/bibsys_logo_medium.jpg</link>
29
			          </links>
30
			        </databaseInfo>
31
			        <metaInfo>
32
			          <dateModified>Sat Apr 26 16:47:43 CEST 2014</dateModified>
33
			        </metaInfo>
34
			        <indexInfo>
35
			          <set identifier="info:srw/cql-context-set/1/dc-v1.1" name="dc"/>
36
			          <set identifier="info:srw/cql-context-set/2/rec-1.1" name="rec"/>
37
			          <set identifier="info:srw/cql-context-set/15/norzig-1.1" name="norzig"/>
38
			          <set identifier="info:srw/cql-context-set/1/bib-v1" name="bib"/>
39
			          <set identifier="http://www.bibsys.no/context/bs/1.0" name="bs"/>
40
			          <set identifier="info:srw/cql-context-set/1/cql-v1.2" name="cql"/>
41
			          <index scan="false" search="true" sort="true">
42
			            <title>Identifiserer en bibliografisk enhet</title>
43
			            <map>
44
			              <name set="bs">objektid</name>
45
			            </map>
46
			          </index>
47
			          <index scan="false" search="true" sort="true">
48
			            <title>An unambiguous reference to the resource within a given context.</title>
49
			            <map>
50
			              <name set="dc">identifier</name>
51
			            </map>
52
			          </index>
53
			          <index scan="false" search="true" sort="true">
54
			            <title>nlm nummer</title>
55
			            <map>
56
			              <name set="bs">nlm</name>
57
			            </map>
58
			          </index>
59
			          <index scan="false" search="true" sort="true">
60
			            <title>institusjonsspesifikke emneord</title>
61
			            <map>
62
			              <name set="bs">ubtsy</name>
63
			            </map>
64
			          </index>
65
			          <index scan="false" search="true" sort="true">
66
			            <title>en plassering</title>
67
			            <map>
68
			              <name set="bs">geografisk-emneord</name>
69
			            </map>
70
			          </index>
71
			          <index scan="false" search="true" sort="true">
72
			            <title/>
73
			            <map>
74
			              <name set="bs">antallinstrumenter</name>
75
			            </map>
76
			          </index>
77
			          <index scan="false" search="true" sort="true">
78
			            <title>intern</title>
79
			            <map>
80
			              <name set="bs">issn-annen-manifestasjon</name>
81
			            </map>
82
			            <map>
83
			              <name set="bs">ismn-annen-manifestasjon</name>
84
			            </map>
85
			            <map>
86
			              <name set="bs">isbn-annen-manifestasjon</name>
87
			            </map>
88
			          </index>
89
			        </indexInfo>
90
			        <schemaInfo>
91
			          <schema identifier="info:srw/schema/1/dc-v1.1" name="dc"/>
92
			          <schema identifier="info:lc/xmlns/marcxchange-v1" name="marcxchange"/>
93
			        </schemaInfo>
94
			        <configInfo>
95
			          <default type="relation">=</default>
96
			          <default type="retrieveSchema">marcxchange</default>
97
			          <default type="numberOfRecords">10</default>
98
			          <setting type="maximumRecords">50</setting>
99
			        </configInfo>
100
			      </explain>
101
			    </sru:recordData>
102
			  </sru:record>
103
			</sru:explainResponse>');
104
105
        $this->assertEquals('1.2', $res->version);
106
        $this->assertEquals('sru.bibsys.no', $res->host);
107
        $this->assertEquals(80, $res->port);
108
        $this->assertEquals('biblio', $res->database->identifier);
109
        $this->assertEquals('BIBSYS Union Catalogue', $res->database->title);
110
        $this->assertEquals('SRU access to the BIBSYS Union Catalogue.', $res->database->description);
111
        $this->assertCount(7, $res->indexes);
112
        $this->assertFalse($res->indexes[0]->scan);
113
        $this->assertTrue($res->indexes[0]->sort);
114
        $this->assertTrue($res->indexes[0]->search);
115
        $this->assertEquals('Identifiserer en bibliografisk enhet', $res->indexes[0]->title);
116
        $this->assertEquals('bs.objektid', $res->indexes[0]->maps[0]);
117
    }
118
119
    public function testCanBeInitializedWithoutAnyData()
120
    {
121
        $res = new ExplainResponse;
122
        $this->assertNull($res->host);
123
    }
124
}
125