forked from filbertkm/WikibaseImport
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApiEntityLookupIntegrationTest.php
More file actions
54 lines (42 loc) · 1.38 KB
/
ApiEntityLookupIntegrationTest.php
File metadata and controls
54 lines (42 loc) · 1.38 KB
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
<?php
namespace Wikibase\Import\Tests;
use Monolog\Logger;
use Monolog\Handler\NullHandler;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\Import\EntityImporterFactory;
use Wikibase\Repo\WikibaseRepo;
/**
* @group WikibaseImport
*/
class ApiEntityLookupIntegrationTest extends \PHPUnit_Framework_TestCase {
public function testGetEntity() {
$apiEntityLookup = $this->getApiEntityLookup();
$item = $apiEntityLookup->getEntity( new ItemId( 'Q60' ) );
$this->assertInstanceOf( 'Wikibase\DataModel\Entity\Item', $item );
$this->assertSame(
'New York City',
$item->getFingerprint()->getLabel( 'en' )->getText(),
'English label is New York City'
);
$statements = $item->getStatements()->getByPropertyId( new PropertyId( 'P17' ) );
foreach ( $statements as $statement ) {
$mainSnakValue = $statement->getMainSnak()->getDataValue();
$this->assertEquals( 'Q30', $mainSnakValue->getEntityId()->getSerialization() );
}
}
private function getApiEntityLookup() {
$entityImporterFactory = new EntityImporterFactory(
WikibaseRepo::getEntityStore(),
wfGetLB(),
$this->newLogger(),
'https://www.wikidata.org/w/api.php'
);
return $entityImporterFactory->getApiEntityLookup();
}
private function newLogger() {
$logger = new Logger( 'wikibase-import' );
$logger->pushHandler( new NullHandler() );
return $logger;
}
}