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

ItemIdParserTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanParseEntityId() 0 6 1
A entityIdProvider() 0 6 1
A testCannotParseInvalidId() 0 6 1
A invalidIdSerializationProvider() 0 13 1
1
<?php
2
3
namespace Wikibase\DataModel\Tests\Entity;
4
5
use PHPUnit_Framework_TestCase;
6
use Wikibase\DataModel\Entity\ItemId;
7
use Wikibase\DataModel\Entity\ItemIdParser;
8
9
/**
10
 * @covers Wikibase\DataModel\Entity\ItemIdParser
11
 *
12
 * @licence GNU GPL v2+
13
 * @author Thiemo Mättig
14
 */
15
class ItemIdParserTest extends PHPUnit_Framework_TestCase {
16
17
	/**
18
	 * @dataProvider entityIdProvider
19
	 */
20
	public function testCanParseEntityId( $idString, ItemId $expected ) {
21
		$parser = new ItemIdParser();
22
		$actual = $parser->parse( $idString );
23
24
		$this->assertEquals( $actual, $expected );
25
	}
26
27
	public function entityIdProvider() {
28
		return array(
29
			array( 'q42', new ItemId( 'Q42' ) ),
30
			array( 'Q1337', new ItemId( 'Q1337' ) ),
31
		);
32
	}
33
34
	/**
35
	 * @dataProvider invalidIdSerializationProvider
36
	 */
37
	public function testCannotParseInvalidId( $invalidIdSerialization ) {
38
		$parser = new ItemIdParser();
39
40
		$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...
41
		$parser->parse( $invalidIdSerialization );
42
	}
43
44
	public function invalidIdSerializationProvider() {
45
		return array(
46
			array( 'FOO' ),
47
			array( null ),
48
			array( 42 ),
49
			array( array() ),
50
			array( '' ),
51
			array( 'q0' ),
52
			array( '1p' ),
53
			array( 'p1' ),
54
			array( 'P100000' ),
55
		);
56
	}
57
58
}
59