1 | <?php |
||
24 | class LegacyItemDeserializerTest extends \PHPUnit_Framework_TestCase { |
||
25 | |||
26 | /** |
||
27 | * @var Deserializer |
||
28 | */ |
||
29 | private $deserializer; |
||
30 | |||
31 | protected function setUp() { |
||
32 | $idDeserializer = new LegacyEntityIdDeserializer( new BasicEntityIdParser() ); |
||
33 | |||
34 | $snakDeserializer = new LegacySnakDeserializer( $this->getMock( 'Deserializers\Deserializer' ) ); |
||
35 | |||
36 | $statementDeserializer = new LegacyStatementDeserializer( |
||
37 | $snakDeserializer, |
||
38 | new LegacySnakListDeserializer( $snakDeserializer ) |
||
39 | ); |
||
40 | |||
41 | $this->deserializer = new LegacyItemDeserializer( |
||
42 | $idDeserializer, |
||
43 | new LegacySiteLinkListDeserializer(), |
||
44 | $statementDeserializer, |
||
45 | new LegacyFingerprintDeserializer() |
||
46 | ); |
||
47 | } |
||
48 | |||
49 | public function invalidSerializationProvider() { |
||
50 | return array( |
||
51 | array( null ), |
||
52 | |||
53 | array( array( |
||
54 | 'links' => array( null ) |
||
55 | ) ), |
||
56 | |||
57 | array( array( |
||
58 | 'claims' => null |
||
59 | ) ), |
||
60 | |||
61 | array( array( |
||
62 | 'claims' => array( null ) |
||
63 | ) ), |
||
64 | |||
65 | array( array( |
||
66 | 'entity' => 42 |
||
67 | ) ), |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @dataProvider invalidSerializationProvider |
||
73 | */ |
||
74 | public function testGivenInvalidSerialization_deserializeThrowsException( $serialization ) { |
||
78 | |||
79 | private function expectDeserializationException() { |
||
82 | |||
83 | public function testGivenEmptyArray_emptyItemIsReturned() { |
||
84 | $this->assertEquals( |
||
89 | |||
90 | public function testGivenLinks_itemHasSiteLinks() { |
||
106 | |||
107 | private function assertDeserialization( $serialization, Item $expectedItem ) { |
||
115 | |||
116 | /** |
||
117 | * @param string $serialization |
||
118 | * |
||
119 | * @return Item |
||
120 | */ |
||
121 | private function itemFromSerialization( $serialization ) { |
||
126 | |||
127 | public function testGivenStatement_itemHasStatement() { |
||
140 | |||
141 | private function newStatement() { |
||
146 | |||
147 | private function newStatementSerialization() { |
||
156 | |||
157 | public function testGivenStatementWithLegacyKey_itemHasStatement() { |
||
170 | |||
171 | /** |
||
172 | * @dataProvider TermListProvider |
||
173 | */ |
||
174 | public function testGivenLabels_getLabelsReturnsThem( array $labels ) { |
||
179 | |||
180 | public function TermListProvider() { |
||
190 | |||
191 | public function testGivenInvalidLabels_exceptionIsThrown() { |
||
195 | |||
196 | /** |
||
197 | * @dataProvider TermListProvider |
||
198 | */ |
||
199 | public function testGivenDescriptions_getDescriptionsReturnsThem( array $descriptions ) { |
||
204 | |||
205 | public function testGivenInvalidAliases_exceptionIsThrown() { |
||
209 | |||
210 | /** |
||
211 | * @dataProvider aliasesListProvider |
||
212 | */ |
||
213 | public function testGivenAliases_getAliasesReturnsThem( array $aliases ) { |
||
218 | |||
219 | public function aliasesListProvider() { |
||
230 | |||
231 | } |
||
232 |