1010
1111/**
1212 * @covers Wikibase\DataModel\Entity\DispatchingEntityIdParser
13- * @covers Wikibase\DataModel\Entity\EntityIdParser
14- *
1513 * @uses Wikibase\DataModel\Entity\BasicEntityIdParser
1614 *
1715 * @group Wikibase
1816 * @group WikibaseDataModel
1917 *
2018 * @licence GNU GPL v2+
2119 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
20+ * @author Thiemo Mättig
2221 */
2322class DispatchingEntityIdParserTest extends \PHPUnit_Framework_TestCase {
2423
@@ -29,28 +28,29 @@ private function getBasicParser() {
2928 /**
3029 * @dataProvider entityIdProvider
3130 */
32- public function testCanParseEntityId ( EntityId $ expected ) {
31+ public function testCanParseEntityId ( $ idString , EntityId $ expected ) {
3332 $ parser = $ this ->getBasicParser ();
34- $ actual = $ parser ->parse ( $ expected -> getSerialization () );
33+ $ actual = $ parser ->parse ( $ idString );
3534
3635 $ this ->assertEquals ( $ actual , $ expected );
3736 }
3837
3938 public function entityIdProvider () {
4039 return array (
41- array ( new ItemId ( 'q42 ' ) ),
42- array ( new ItemId ( 'Q1337 ' ) ),
43- array ( new PropertyId ( 'p1 ' ) ),
44- array ( new PropertyId ( 'P100000 ' ) ),
40+ array ( ' q42 ' , new ItemId ( 'q42 ' ) ),
41+ array ( ' Q1337 ' , new ItemId ( 'Q1337 ' ) ),
42+ array ( ' p1 ' , new PropertyId ( 'p1 ' ) ),
43+ array ( ' P100000 ' , new PropertyId ( 'P100000 ' ) ),
4544 );
4645 }
4746
4847 /**
4948 * @dataProvider invalidIdSerializationProvider
50- * @expectedException \Wikibase\DataModel\Entity\EntityIdParsingException
5149 */
5250 public function testCannotParseInvalidId ( $ invalidIdSerialization ) {
5351 $ parser = $ this ->getBasicParser ();
52+
53+ $ this ->setExpectedException ( 'Wikibase\DataModel\Entity\EntityIdParsingException ' );
5454 $ parser ->parse ( $ invalidIdSerialization );
5555 }
5656
@@ -66,4 +66,11 @@ public function invalidIdSerializationProvider() {
6666 );
6767 }
6868
69+ public function testCannotParseWithoutBuilders () {
70+ $ parser = new DispatchingEntityIdParser ( array () );
71+
72+ $ this ->setExpectedException ( 'Wikibase\DataModel\Entity\EntityIdParsingException ' );
73+ $ parser ->parse ( 'Q1 ' );
74+ }
75+
6976}
0 commit comments