These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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
|
|||
| 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 |
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.