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
|
|
|
|