Skip to content

Commit 81e7f4d

Browse files
committed
refactor: Move tests into CollectionTest
1 parent 14d0925 commit 81e7f4d

File tree

6 files changed

+55
-86
lines changed

6 files changed

+55
-86
lines changed

tests/CollectionTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,57 @@ public function testEmptyCollection()
1414
$collection = Collection::fromString($source);
1515
$this->assertCount(0, $collection->toArray());
1616
}
17+
18+
public function testBibsysOaiPmhSample()
19+
{
20+
$collection = Collection::fromFile('tests/data/oaipmh-bibsys.xml');
21+
22+
$this->assertCount(89, $collection->toArray());
23+
}
24+
25+
/**
26+
* @expectedException Scriptotek\Marc\Exceptions\XmlException
27+
*/
28+
public function testAlmaBibsApiExample()
29+
{
30+
// Expect failure because of invalid encoding in XML declaration:
31+
// Document labelled UTF-16 but has UTF-8 content
32+
Collection::fromFile('tests/data/alma-bibs-api-invalid.xml');
33+
}
34+
35+
public function testLocSample()
36+
{
37+
$collection = Collection::fromFile('tests/data/sru-loc.xml');
38+
39+
$this->assertCount(10, $collection->toArray());
40+
}
41+
42+
public function testBibsysSample()
43+
{
44+
$collection = Collection::fromFile('tests/data/sru-bibsys.xml');
45+
46+
$this->assertCount(117, $collection->toArray());
47+
}
48+
49+
public function testZdbSample()
50+
{
51+
$collection = Collection::fromFile('tests/data/sru-zdb.xml');
52+
53+
$this->assertCount(8, $collection->toArray());
54+
}
55+
56+
public function testKthSample()
57+
{
58+
$collection = Collection::fromFile('tests/data/sru-kth.xml');
59+
60+
$this->assertCount(10, $collection->toArray());
61+
}
62+
63+
public function testAlmaSample()
64+
{
65+
$collection = Collection::fromFile('tests/data/sru-alma.xml');
66+
67+
$this->assertCount(3, $collection->toArray());
68+
}
69+
1770
}

tests/InvalidRecordTest.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/OaiPmhResponseTest.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/SruResponseTest.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/SubjectFieldTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
22

3-
use Scriptotek\Marc\Importers\XmlImporter;
3+
use Scriptotek\Marc\Collection;
44

55
class SubjectFieldTest extends \PHPUnit_Framework_TestCase
66
{
77
protected function getNthrecord($n)
88
{
9-
$response = new XmlImporter('tests/data/sru-alma.xml');
10-
$records = $response->getCollection()->toArray();
9+
$records = Collection::fromFile('tests/data/sru-alma.xml')->toArray();
1110

1211
return $records[$n - 1];
1312
}

tests/XmlImporterTest.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)