@@ -34,12 +34,31 @@ public function testPostArchive(): void
3434 $ id = $ json ['id ' ];
3535 $ this ->assertMatchesRegularExpression ('#^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$# ' , $ id );
3636 $ this ->assertEquals ($ identifier , $ json ['identifier ' ]);
37- $ this ->assertEquals ('created ' , $ json ['status ' ]);
37+ $ this ->assertEquals ('ready ' , $ json ['status ' ]);
3838 $ this ->assertArrayHasKey ('downloadUrl ' , $ json );
3939 $ this ->assertMatchesRegularExpression (sprintf ('#^http://localhost/archives/%s/download\?jwt=.+$# ' , $ id ), $ json ['downloadUrl ' ]);
4040
4141 $ archive = $ this ->getArchiveFromDatabase ($ id );
4242 $ this ->expectedFiles ($ files , $ archive );
43+
44+ $ archivePath = $ this ->getArchiveDir ().DIRECTORY_SEPARATOR .$ id .'.zip ' ;
45+ $ this ->assertTrue (file_exists ($ archivePath ));
46+
47+ $ response = $ this ->request ('GET ' , $ json ['downloadUrl ' ]);
48+ $ html = $ response ->getContent ();
49+ if (1 !== preg_match ('#document\.location = \'([^ \']+) \'# ' , $ html , $ matches )) {
50+ throw new \Exception ('Cannot find redirect location in HTML ' );
51+ }
52+ $ downloadUrl = $ matches [1 ];
53+
54+ ob_start ();
55+ ob_start ();
56+ $ response = $ this ->request ('GET ' , $ downloadUrl );
57+ ob_end_clean ();
58+ ob_end_clean ();
59+ $ this ->assertEquals ('attachment; filename="foo.zip" ' , $ response ->getHeaders ()['content-disposition ' ][0 ]);
60+
61+ $ this ->removeArchive ($ id );
4362 }
4463
4564 public function testPutArchiveReturnsMethodNotAllowed (): void
0 commit comments