Completed
Push — master ( cc9861...ce61c8 )
by mw
91:08 queued 55:59
created

ImporterIntegrationTest::testValidXmlContent()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 0
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
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
		if ( !interface_exists( '\ImportSource' ) ) {
58
			$this->markTestSkipped( "ImportSource interface is unknown (MW 1.25-)" );
59
		}
60
61
		$importFileDir = $this->testEnvironment->getFixturesLocation( 'Importer/ValidXmlContent' );
62
63
		$importer = $this->importServicesFactory->newImporter(
64
			$this->importServicesFactory->newJsonContentIterator( $importFileDir )
65
		);
66
67
		$importer->setMessageReporter( $this->spyMessageReporter );
68
		$importer->setReqVersion( 1 );
69
70
		$importer->doImport();
71
72
		$this->stringValidator->assertThatStringContains(
73
			array(
74
				'ImportTest'
75
			),
76
			$this->spyMessageReporter->getMessagesAsString()
77
		);
78
	}
79
80
}
81