Completed
Push — master ( 813ff2...07dd29 )
by mw
377:22 queued 342:34
created

ImporterIntegrationTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
dl 0
loc 60
c 0
b 0
f 0
rs 10
wmc 3
lcom 1
cbo 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A testValidTextContent() 0 21 1
A testValidXmlContent() 0 20 1
1
<?php
2
3
namespace SMW\Tests\Integration\Importer;
4
5
use SMW\Tests\MwDBaseUnitTestCase;
6
use SMW\ApplicationFactory;
7
8
/**
9
 * @group semantic-mediawiki
10
 * @group medium
11
 *
12
 * @license GNU GPL v2+
13
 * @since 3.0
14
 *
15
 * @author mwjames
16
 */
17
class ImporterIntegrationTest extends MwDBaseUnitTestCase {
18
19
	private $spyMessageReporter;
20
	private $importServicesFactory;
21
	private $stringValidator;
22
23
	protected function setUp() {
24
		parent::setUp();
25
26
		$utilityFactory = $this->testEnvironment->getUtilityFactory();
27
28
		$this->importServicesFactory = ApplicationFactory::getInstance()->create( 'ImportServicesFactory' );
29
		$this->spyMessageReporter = $utilityFactory->newSpyMessageReporter();
30
		$this->stringValidator = $utilityFactory->newValidatorFactory()->newStringValidator();
31
	}
32
33
	public function testValidTextContent() {
34
35
		$importFileDir = $this->testEnvironment->getFixturesLocation( 'Importer/ValidTextContent' );
36
37
		$importer = $this->importServicesFactory->newImporter(
38
			$this->importServicesFactory->newJsonContentIterator( $importFileDir )
39
		);
40
41
		$importer->setMessageReporter( $this->spyMessageReporter );
42
		$importer->setReqVersion( 1 );
43
44
		$importer->doImport();
45
46
		$this->stringValidator->assertThatStringContains(
47
			array(
48
				'Smw import foaf',
49
				'Foaf:knows'
50
			),
51
			$this->spyMessageReporter->getMessagesAsString()
52
		);
53
	}
54
55
	public function testValidXmlContent() {
56
57
		$importFileDir = $this->testEnvironment->getFixturesLocation( 'Importer/ValidXmlContent' );
58
59
		$importer = $this->importServicesFactory->newImporter(
60
			$this->importServicesFactory->newJsonContentIterator( $importFileDir )
61
		);
62
63
		$importer->setMessageReporter( $this->spyMessageReporter );
64
		$importer->setReqVersion( 1 );
65
66
		$importer->doImport();
67
68
		$this->stringValidator->assertThatStringContains(
69
			array(
70
				'ImportTest'
71
			),
72
			$this->spyMessageReporter->getMessagesAsString()
73
		);
74
	}
75
76
}
77