Completed
Push — coverageversiong ( 2761c4 )
by Jeroen De
12:52 queued 07:07
created

BasicEntityIdParserTest::entityIdProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\DataModel\Tests\Entity;
4
5
use Wikibase\DataModel\Entity\BasicEntityIdParser;
6
use Wikibase\DataModel\Entity\EntityId;
7
use Wikibase\DataModel\Entity\ItemId;
8
use Wikibase\DataModel\Entity\PropertyId;
9
10
/**
11
 * @covers Wikibase\DataModel\Entity\BasicEntityIdParser
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 * @author Thiemo Mättig
16
 */
17
class BasicEntityIdParserTest extends \PHPUnit_Framework_TestCase {
18
19
	/**
20
	 * @dataProvider entityIdProvider
21
	 */
22
	public function testCanParseEntityId( $idString, EntityId $expected ) {
23
		$parser = new BasicEntityIdParser();
24
		$actual = $parser->parse( $idString );
25
26
		$this->assertEquals( $actual, $expected );
27
	}
28
29
	public function entityIdProvider() {
30
		return array(
31
			array( 'q42', new ItemId( 'q42' ) ),
32
			array( 'Q1337', new ItemId( 'Q1337' ) ),
33
			array( 'p1', new PropertyId( 'p1' ) ),
34
			array( 'P100000', new PropertyId( 'P100000' ) ),
35
		);
36
	}
37
38
	/**
39
	 * @dataProvider invalidIdSerializationProvider
40
	 */
41
	public function testCannotParseInvalidId( $invalidIdSerialization ) {
42
		$parser = new BasicEntityIdParser();
43
44
		$this->setExpectedException( 'Wikibase\DataModel\Entity\EntityIdParsingException' );
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...
45
		$parser->parse( $invalidIdSerialization );
46
	}
47
48
	public function invalidIdSerializationProvider() {
49
		return array(
50
			array( 'FOO' ),
51
			array( null ),
52
			array( 42 ),
53
			array( array() ),
54
			array( '' ),
55
			array( 'q0' ),
56
			array( '1p' ),
57
		);
58
	}
59
60
}
61