protected function setUp() { parent::setUp(); if (!defined('WB_VERSION')) { $this->markTestSkipped('Entity info tables are not available locally on the client'); } $this->tablesUsed[] = 'wb_property_info'; $this->tablesUsed[] = 'wb_terms'; $this->tablesUsed[] = 'wb_entity_per_page'; $termRows = array(); $infoRows = array(); $eppRows = array(); $pageId = 1000; foreach ($this->getKnownEntities() as $entity) { $eppRows[] = array($entity->getType(), $entity->getId()->getNumericId(), $pageId++, null); $labels = $entity->getFingerprint()->getLabels()->toTextArray(); $descriptions = $entity->getFingerprint()->getDescriptions()->toTextArray(); $aliases = $entity->getFingerprint()->getAliasGroups()->toTextArray(); $termRows = array_merge($termRows, $this->getTermRows($entity->getId(), 'label', $labels)); $termRows = array_merge($termRows, $this->getTermRows($entity->getId(), 'description', $descriptions)); $termRows = array_merge($termRows, $this->getTermRows($entity->getId(), 'alias', $aliases)); if ($entity instanceof Property) { $infoRows[] = array($entity->getId()->getNumericId(), $entity->getDataTypeId(), '{"type":"' . $entity->getDataTypeId() . '"}'); } } foreach ($this->getKnownRedirects() as $from => $toId) { $fromId = new ItemId($from); $eppRows[] = array($fromId->getEntityType(), $fromId->getNumericId(), $pageId++, $toId->getSerialization()); } $this->insertRows('wb_terms', array('term_entity_type', 'term_entity_id', 'term_type', 'term_language', 'term_text', 'term_search_key'), $termRows); $this->insertRows('wb_property_info', array('pi_property_id', 'pi_type', 'pi_info'), $infoRows); $eppColumns = array('epp_entity_type', 'epp_entity_id', 'epp_page_id', 'epp_redirect_target'); $this->insertRows('wb_entity_per_page', $eppColumns, $eppRows); }
public function testGetNamespaceForType() { $factory = $this->newFactory(); $id = new ItemId('Q42'); $ns = $factory->getNamespaceForType($id->getEntityType()); $this->assertGreaterThanOrEqual(0, $ns, 'namespace'); }
public function testGetEntityType() { $id = new ItemId('Q1'); $this->assertSame('item', $id->getEntityType()); }