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