This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -501,6 +501,36 @@ public function testOpenTempStreamWithValidFileDoesntThrowsException()
501
501
// @todo verify link is still active
502
502
}
503
503
504
+ /**
505
+ * Test if a downloaded file can be deleted
506
+ *
507
+ * @group ZF-9685
508
+ */
509
+ public function testDownloadedFileCanBeDeleted ()
510
+ {
511
+ if (! getenv ('TESTS_ZEND_HTTP_CLIENT_ONLINE ' )) {
512
+ $ this ->markTestSkipped ('Zend\Http\Client online tests are not enabled ' );
513
+ }
514
+ $ url = 'http://www.example.com/ ' ;
515
+ $ outputFile = @tempnam (@sys_get_temp_dir (), 'zht ' );
516
+ if (!is_file ($ outputFile )) {
517
+ $ this ->markTestSkipped ('Failed to create a temporary file ' );
518
+ }
519
+ $ config = [
520
+ 'outputstream ' => $ outputFile ,
521
+ ];
522
+ $ client = new HTTPClient ($ url , $ config );
523
+
524
+ $ result = $ client ->send ();
525
+
526
+ $ this ->assertInstanceOf ('Zend\Http\Response\Stream ' , $ result );
527
+ if (DIRECTORY_SEPARATOR === '\\' ) {
528
+ $ this ->assertFalse (@unlink ($ outputFile ), 'Deleting an open file should fail on Windows ' );
529
+ }
530
+ fclose ($ result ->getStream ());
531
+ $ this ->assertTrue (@unlink ($ outputFile ), 'Failed to delete downloaded file ' );
532
+ }
533
+
504
534
/**
505
535
* Testing if the connection can be closed
506
536
*
You can’t perform that action at this time.
0 commit comments