1 | <?php |
||
22 | class WikibaseEntityIdParserTest extends ValueParserTestBase { |
||
23 | |||
24 | /** |
||
25 | * @see ValueParserTestBase::validInputProvider |
||
26 | */ |
||
27 | public function validInputProvider() { |
||
28 | return array( |
||
29 | array( |
||
30 | 'Douglas Adams', |
||
31 | array( |
||
32 | new EntityIdValue(new ItemId('Q42')), |
||
33 | new EntityIdValue(new ItemId('Q21454969')), |
||
34 | new EntityIdValue(new ItemId('Q25212461')) |
||
35 | ) |
||
36 | ), |
||
37 | array( |
||
38 | 'Barack Obama', |
||
39 | array(new EntityIdValue(new ItemId('Q76'))) |
||
40 | ), |
||
41 | array( |
||
42 | 'P=NP', |
||
43 | array(new EntityIdValue(new ItemId('Q746242'))) |
||
44 | ), |
||
45 | array( |
||
46 | 'TUNGSTÈNE', |
||
47 | array( |
||
48 | new EntityIdValue(new ItemId('Q743')), |
||
49 | new EntityIdValue(new ItemId('Q3542087')) |
||
50 | ) |
||
51 | ), |
||
52 | array( |
||
53 | 'Barack Obama', |
||
54 | array(new EntityIdValue(new ItemId('Q76'))) |
||
55 | ), |
||
56 | array( |
||
57 | '', |
||
58 | array() |
||
59 | ), |
||
60 | array( |
||
61 | 'abcabcabc', |
||
62 | array() |
||
63 | ), |
||
64 | array( |
||
65 | 'q42', |
||
66 | array(new EntityIdValue(new ItemId('Q42'))) |
||
67 | ), |
||
68 | array( |
||
69 | 'VIAF', |
||
70 | array(new EntityIdValue(new PropertyId('P214'))), |
||
71 | $this->getInstance('property') |
||
72 | ), |
||
73 | array( |
||
74 | 'P214', |
||
75 | array(new EntityIdValue(new PropertyId('P214'))), |
||
76 | $this->getInstance('property') |
||
77 | ), |
||
78 | ); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @see ValueParserTestBase::invalidInputProvider |
||
83 | */ |
||
84 | public function invalidInputProvider() { |
||
85 | return array( |
||
86 | array( |
||
87 | new ItemId('Q23') |
||
88 | ) |
||
89 | ); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @see ValueParserTestBase::getInstance |
||
94 | */ |
||
95 | protected function getInstance($entityType = 'item') { |
||
96 | return new WikibaseEntityIdParser( |
||
97 | new ApiEntityStore(new MediawikiApi('http://www.wikidata.org/w/api.php')), |
||
98 | $this->newParserOptions($entityType) |
||
99 | ); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @see ValueParserTestBase::newParserOptions |
||
104 | */ |
||
105 | protected function newParserOptions($entityType = 'item') { |
||
106 | $parserOptions = new ParserOptions(); |
||
107 | |||
108 | $parserOptions->setOption(ValueParser::OPT_LANG, 'fr'); |
||
109 | $parserOptions->setOption(WikibaseEntityIdParser::OPT_ENTITY_TYPE, $entityType); |
||
110 | |||
111 | return $parserOptions; |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @return ValueParserTestBase::requireDataValue |
||
|
|||
116 | */ |
||
117 | protected function requireDataValue() { |
||
120 | } |
||
121 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.