|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Wikibase\DataModel\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Wikibase\DataModel\Entity\EntityId; |
|
6
|
|
|
use Wikibase\DataModel\Entity\ItemId; |
|
7
|
|
|
use Wikibase\DataModel\Entity\PropertyId; |
|
8
|
|
|
use Wikibase\DataModel\LegacyIdInterpreter; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @covers Wikibase\DataModel\LegacyIdInterpreter |
|
12
|
|
|
* |
|
13
|
|
|
* @group Wikibase |
|
14
|
|
|
* @group WikibaseDataModel |
|
15
|
|
|
* |
|
16
|
|
|
* @licence GNU GPL v2+ |
|
17
|
|
|
* @author Katie FIlbert < [email protected] > |
|
18
|
|
|
*/ |
|
19
|
|
|
class LegacyIdInterpreterTest extends \PHPUnit_Framework_TestCase { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @dataProvider idProvider |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testNewIdFromTypeAndNumber( EntityId $expected, $type, $number ) { |
|
25
|
|
|
$actual = LegacyIdInterpreter::newIdFromTypeAndNumber( $type, $number ); |
|
26
|
|
|
|
|
27
|
|
|
$this->assertEquals( $actual, $expected ); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function idProvider() { |
|
31
|
|
|
return array( |
|
32
|
|
|
array( new ItemId( 'Q42' ), 'item', 42 ), |
|
33
|
|
|
array( new PropertyId( 'P42' ), 'property', 42 ), |
|
34
|
|
|
); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @dataProvider invalidInputProvider |
|
39
|
|
|
*/ |
|
40
|
|
|
public function testNewIdFromTypeAndNumber_withInvalidInput( $type, $number ) { |
|
41
|
|
|
$this->setExpectedException( 'InvalidArgumentException' ); |
|
|
|
|
|
|
42
|
|
|
LegacyIdInterpreter::newIdFromTypeAndNumber( $type, $number ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function invalidInputProvider() { |
|
46
|
|
|
return array( |
|
47
|
|
|
array( 'kittens', 42 ), |
|
48
|
|
|
array( 'item', array( 'kittens' ) ), |
|
49
|
|
|
array( 'item', true ), |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.