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\Services\Tests\Statement; |
||
4 | |||
5 | use Wikibase\DataModel\Entity\ItemId; |
||
6 | use Wikibase\DataModel\Entity\ItemIdParser; |
||
7 | use Wikibase\DataModel\Services\Statement\StatementGuidParser; |
||
8 | use Wikibase\DataModel\Services\Statement\StatementGuidParsingException; |
||
9 | use Wikibase\DataModel\Statement\StatementGuid; |
||
10 | |||
11 | /** |
||
12 | * @covers Wikibase\DataModel\Services\Statement\StatementGuidParser |
||
13 | * |
||
14 | * @license GPL-2.0+ |
||
15 | * @author Addshore |
||
16 | */ |
||
17 | class StatementGuidParserTest extends \PHPUnit_Framework_TestCase { |
||
18 | |||
19 | /** |
||
20 | * @dataProvider guidProvider |
||
21 | */ |
||
22 | public function testCanParseStatementGuid( StatementGuid $expected ) { |
||
23 | $actual = $this->newParser()->parse( $expected->getSerialization() ); |
||
0 ignored issues
–
show
|
|||
24 | |||
25 | $this->assertEquals( $actual, $expected ); |
||
26 | } |
||
27 | |||
28 | private function newParser() { |
||
29 | return new StatementGuidParser( new ItemIdParser() ); |
||
30 | } |
||
31 | |||
32 | public function guidProvider() { |
||
33 | return [ |
||
34 | [ new StatementGuid( new ItemId( 'q42' ), 'D8404CDA-25E4-4334-AF13-A3290BCD9C0N' ) ], |
||
35 | [ new StatementGuid( new ItemId( 'Q1234567' ), 'D4FDE516-F20C-4154-ADCE-7C5B609DFDFF' ) ], |
||
36 | [ new StatementGuid( new ItemId( 'Q1' ), 'foo' ) ], |
||
37 | [ new StatementGuid( new ItemId( 'Q1' ), '$' ) ], |
||
38 | [ new StatementGuid( new ItemId( 'Q1' ), '' ) ], |
||
39 | ]; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @dataProvider invalidIdSerializationProvider |
||
44 | */ |
||
45 | public function testCannotParserInvalidId( $invalidIdSerialization ) { |
||
46 | $this->setExpectedException( StatementGuidParsingException::class ); |
||
47 | $this->newParser()->parse( $invalidIdSerialization ); |
||
48 | } |
||
49 | |||
50 | public function invalidIdSerializationProvider() { |
||
51 | return [ |
||
52 | [ 'FOO' ], |
||
53 | [ null ], |
||
54 | [ 42 ], |
||
55 | [ [] ], |
||
56 | [ '' ], |
||
57 | [ 'q0' ], |
||
58 | [ '1p' ], |
||
59 | [ 'Q0$5627445f-43cb-ed6d-3adb-760e85bd17ee' ], |
||
60 | [ 'Q1' ], |
||
61 | ]; |
||
62 | } |
||
63 | |||
64 | } |
||
65 |
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.