Passed
Push — entityIdInjection ( 21ce29...71be9d )
by no
05:51
created

LegacyIdInterpreterTest::invalidInputProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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.

Loading history...
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