@@ -134,23 +134,59 @@ public function testSerializeAttachment(Attachment $attachment, $expectedJson)
134134
135135 public function serializeAttachmentData ()
136136 {
137- return $ this ->buildSerializeTestCases ('Attachment ' );
137+ $ tests = array ();
138+
139+ foreach (get_class_methods ('Xabbuh\XApi\DataFixtures\AttachmentFixtures ' ) as $ method ) {
140+ if (false !== strpos ($ method , 'ForQuery ' )) {
141+ continue ;
142+ }
143+
144+ $ jsonFixture = json_decode (call_user_func (array ('XApi\Fixtures\Json\AttachmentJsonFixtures ' , $ method )));
145+
146+ $ tests [$ method ] = array (
147+ call_user_func (array ('Xabbuh\XApi\DataFixtures\AttachmentFixtures ' , $ method )),
148+ json_encode ($ jsonFixture ->metadata ),
149+ );
150+ }
151+
152+ return $ tests ;
138153 }
139154
140155 /**
141156 * @dataProvider deserializeAttachmentData
142157 */
143- public function testDeserializeAttachment ($ json , Attachment $ expectedAttachment )
158+ public function testDeserializeAttachment ($ json , $ content , Attachment $ expectedAttachment )
144159 {
145- $ attachment = $ this ->serializer ->deserialize ($ json , 'Xabbuh\XApi\Model\Attachment ' , 'json ' );
160+ $ context = array ();
161+
162+ if (null !== $ content ) {
163+ $ context ['xapi_attachments ' ] = array (
164+ hash ('sha256 ' , $ content ) => array (
165+ 'content ' => $ content ,
166+ )
167+ );
168+ }
169+
170+ $ attachment = $ this ->serializer ->deserialize ($ json , 'Xabbuh\XApi\Model\Attachment ' , 'json ' , $ context );
146171
147172 $ this ->assertInstanceOf ('Xabbuh\XApi\Model\Attachment ' , $ attachment );
148173 $ this ->assertTrue ($ expectedAttachment ->equals ($ attachment ), 'Deserialized attachment has the expected properties ' );
149174 }
150175
151176 public function deserializeAttachmentData ()
152177 {
153- return $ this ->buildDeserializeTestCases ('Attachment ' );
178+ $ tests = array ();
179+
180+ foreach (get_class_methods ('XApi\Fixtures\Json\AttachmentJsonFixtures ' ) as $ method ) {
181+ $ jsonFixture = json_decode (call_user_func (array ('XApi\Fixtures\Json\AttachmentJsonFixtures ' , $ method )));
182+ $ tests [$ method ] = array (
183+ json_encode ($ jsonFixture ->metadata ),
184+ isset ($ jsonFixture ->content ) ? $ jsonFixture ->content : null ,
185+ call_user_func (array ('Xabbuh\XApi\DataFixtures\AttachmentFixtures ' , $ method )),
186+ );
187+ }
188+
189+ return $ tests ;
154190 }
155191
156192 /**
0 commit comments