1 | <?php |
||
24 | class PropertySomeValueSnakTest extends PHPUnit_Framework_TestCase { |
||
25 | |||
26 | /** |
||
27 | * @dataProvider validConstructorArgumentsProvider |
||
28 | */ |
||
29 | public function testConstructor( $propertyId ) { |
||
33 | |||
34 | public function validConstructorArgumentsProvider() { |
||
41 | |||
42 | /** |
||
43 | * @dataProvider invalidConstructorArgumentsProvider |
||
44 | * @expectedException InvalidArgumentException |
||
45 | */ |
||
46 | public function testGivenInvalidConstructorArguments_constructorThrowsException( $propertyId ) { |
||
49 | |||
50 | public function invalidConstructorArgumentsProvider() { |
||
58 | |||
59 | public function testGetPropertyId() { |
||
64 | |||
65 | public function testGetHash() { |
||
71 | |||
72 | /** |
||
73 | * This test is a safeguard to make sure hashes are not changed unintentionally. |
||
74 | */ |
||
75 | public function testHashStability() { |
||
82 | |||
83 | public function testEquals() { |
||
89 | |||
90 | /** |
||
91 | * @dataProvider notEqualsProvider |
||
92 | */ |
||
93 | public function testGivenDifferentSnaks_EqualsReturnsFalse( Snak $snak1, Snak $snak2 ) { |
||
97 | |||
98 | public function notEqualsProvider() { |
||
112 | |||
113 | public function provideDataToSerialize() { |
||
114 | $p2 = new PropertyId( 'P2' ); |
||
115 | $p2foo = new PropertyId( 'foo:P2' ); |
||
116 | |||
117 | return [ |
||
118 | 'string' => [ |
||
119 | 'P2', |
||
120 | new PropertySomeValueSnak( $p2 ), |
||
121 | ], |
||
122 | 'foreign' => [ |
||
123 | 'foo:P2', |
||
124 | new PropertySomeValueSnak( $p2foo ), |
||
125 | ], |
||
126 | ]; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @dataProvider provideDataToSerialize |
||
131 | */ |
||
132 | public function testSerialize( $expected, Snak $snak ) { |
||
140 | |||
141 | public function provideDataToUnserialize() { |
||
142 | $p2 = new PropertyId( 'P2' ); |
||
143 | $p2foo = new PropertyId( 'foo:P2' ); |
||
144 | |||
145 | return [ |
||
146 | 'legacy' => [ new PropertySomeValueSnak( $p2 ), 'i:2;' ], |
||
147 | 'current' => [ new PropertySomeValueSnak( $p2 ), 'P2' ], |
||
148 | 'foreign' => [ new PropertySomeValueSnak( $p2foo ), 'foo:P2' ], |
||
149 | ]; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * @dataProvider provideDataToUnserialize |
||
154 | */ |
||
155 | public function testUnserialize( $expected, $serialized ) { |
||
160 | |||
161 | } |
||
162 |