Completed
Push — detect-covers-fails ( bd35c8...c3f051 )
by no
16:27 queued 12:25
created

invalidIdSerializationProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
c 1
b 0
f 0
rs 9.4286
cc 1
eloc 9
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' );
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