1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Wikibase\DataModel\Services\Tests\EntityId; |
4
|
|
|
|
5
|
|
|
use PHPUnit_Framework_TestCase; |
6
|
|
|
use Wikibase\DataModel\Entity\EntityId; |
7
|
|
|
use Wikibase\DataModel\Entity\ItemId; |
8
|
|
|
use Wikibase\DataModel\Entity\PropertyId; |
9
|
|
|
use Wikibase\DataModel\Services\EntityId\PlainEntityIdFormatter; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @covers Wikibase\DataModel\Services\EntityId\PlainEntityIdFormatter |
13
|
|
|
* |
14
|
|
|
* @license GPL-2.0+ |
15
|
|
|
* @author Jeroen De Dauw < [email protected] > |
16
|
|
|
*/ |
17
|
|
|
class PlainEntityIdFormatterTest extends PHPUnit_Framework_TestCase { |
18
|
|
|
|
19
|
|
|
public function validProvider() { |
20
|
|
|
$argLists = []; |
21
|
|
|
|
22
|
|
|
$argLists[] = [ new ItemId( 'q42' ), 'Q42' ]; |
23
|
|
|
$argLists[] = [ new ItemId( 'q9001' ), 'Q9001' ]; |
24
|
|
|
$argLists[] = [ new ItemId( 'q1' ), 'Q1' ]; |
25
|
|
|
|
26
|
|
|
$argLists[] = [ new PropertyId( 'p42' ), 'P42' ]; |
27
|
|
|
$argLists[] = [ new PropertyId( 'p9001' ), 'P9001' ]; |
28
|
|
|
$argLists[] = [ new PropertyId( 'p1' ), 'P1' ]; |
29
|
|
|
|
30
|
|
|
return $argLists; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @dataProvider validProvider |
35
|
|
|
* |
36
|
|
|
* @param EntityId $entityId |
37
|
|
|
* @param string $expectedString |
38
|
|
|
*/ |
39
|
|
|
public function testParseWithValidArguments( EntityId $entityId, $expectedString ) { |
40
|
|
|
$formatter = new PlainEntityIdFormatter(); |
41
|
|
|
|
42
|
|
|
$formattingResult = $formatter->formatEntityId( $entityId ); |
43
|
|
|
|
44
|
|
|
$this->assertInternalType( 'string', $formattingResult ); |
45
|
|
|
$this->assertEquals( $expectedString, $formattingResult ); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
} |
49
|
|
|
|