IncrementalXmlDumpReaderTest::testIterator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
namespace Wikibase\EntityStore\Internal;
4
5
/**
6
 * @covers Wikibase\EntityStore\Internal\IncrementalXmlDumpReader
7
 *
8
 * @licence GPLv2+
9
 * @author Thomas Pellissier Tanon
10
 */
11
class IncrementalXmlDumpReaderTest extends \PHPUnit_Framework_TestCase {
12
13
	private function getReader( $fileName ) {
14
		$serialization = new EntitySerializationFactory();
15
		$logger = $this->getMock( 'Psr\Log\LoggerInterface' );
16
17
		return new IncrementalXmlDumpReader(
18
			__DIR__ . '/../../data/' . $fileName,
19
			$serialization->newEntityDeserializer(),
20
			$logger
21
		);
22
	}
23
24
	/**
25
	 * @dataProvider iteratorProvider
26
	 */
27
	public function testIterator( $fileName, $expectedEntities ) {
28
		$entityIds = [];
29
30
		foreach( $this->getReader( $fileName ) as $entity ) {
31
			$entityIds[] = $entity->getId()->getSerialization();
32
		}
33
34
		$this->assertEquals( $expectedEntities, $entityIds );
35
	}
36
37
	public function iteratorProvider() {
38
		return [
39
			[
40
				'valid-incremental.xml',
41
				[ 'Q12662', 'P1' ]
42
			]
43
		];
44
	}
45
}
46