@@ -374,6 +374,44 @@ public function testMoreStatementsWithAttachments() {
374374 $ this ->assertInstanceOf ('TinCan\StatementsResult ' , $ response ->content , 'content ' );
375375 }
376376
377+ public function testRetrieveStatementWithFileUrlAttachments () {
378+ $ lrs = new RemoteLRS (self ::$ endpoint , self ::$ version , self ::$ username , self ::$ password );
379+ $ attachments = new Attachment ();
380+ $ attachmentUrl = 'https://github.com/RusticiSoftware/TinCanPHP/raw/master/tests/files/image.jpg ' ;
381+ // Store Attachments in and retrieve them from the LRS
382+ $ attachments
383+ ->setUsageType ('http://id.tincanapi.com/attachment/supporting_media ' )
384+ ->setDisplay (['en-US ' => 'Test image attachment ' ])
385+ ->setContentType ('image/jpg ' )
386+ ->setLength (filesize ('tests/files/image.jpg ' ))
387+ ->setSha2 (hash_file ('sha256 ' , 'tests/files/image.jpg ' )) // hash of the attachment data
388+ ->setFileUrl ($ attachmentUrl )
389+ ->setDescription (['en-US ' => 'A test document used in an Attachments object example. ' ]);
390+
391+ // Compose statement for sending to the LRS
392+ $ statement = new Statement (
393+ [
394+ 'actor ' => [
395+ 'mbox ' => COMMON_MBOX
396+ ],
397+ 'verb ' => [
398+ 'id ' => COMMON_VERB_ID
399+ ],
400+ 'object ' => new Activity ([
401+ 'id ' => COMMON_ACTIVITY_ID
402+ ])
403+ ]
404+ );
405+ $ statement ->setAttachments ([$ attachments ]);
406+ $ saveResponse = $ lrs ->saveStatement ($ statement );
407+ $ statementResponse = $ lrs ->retrieveStatement ($ saveResponse ->content ->getId (), ['attachments ' => true ]);
408+
409+ $ this ->assertInstanceOf ('TinCan\LRSResponse ' , $ statementResponse );
410+ $ this ->assertTrue ($ statementResponse ->success );
411+ $ this ->assertInstanceOf ('TinCan\Statement ' , $ statementResponse ->content );
412+ $ this ->assertEquals ($ attachmentUrl , $ statementResponse ->content ->getAttachments ()[0 ]->getFileUrl ());
413+ }
414+
377415 public function testRetrieveStateIds () {
378416 $ lrs = new RemoteLRS (self ::$ endpoint , self ::$ version , self ::$ username , self ::$ password );
379417 $ response = $ lrs ->retrieveStateIds (
0 commit comments