@@ -1624,7 +1624,7 @@ public function userHasUploadedAFileTo(string $user, string $source, string $des
16241624 * @param array|null $headers
16251625 * @param int|null $noOfChunks Only use for chunked upload when $this->chunkingToUse is not null
16261626 *
1627- * @return void
1627+ * @return ResponseInterface
16281628 * @throws Exception
16291629 */
16301630 public function uploadFileWithHeaders (
@@ -1633,25 +1633,27 @@ public function uploadFileWithHeaders(
16331633 string $ destination ,
16341634 ?array $ headers = [],
16351635 ?int $ noOfChunks = 0
1636- ):void {
1637- try {
1638- $ this ->pauseUploadDelete ();
1639- $ this ->response = UploadHelper::upload (
1640- $ this ->getBaseUrl (),
1641- $ this ->getActualUsername ($ user ),
1642- $ this ->getUserPassword ($ user ),
1643- $ source ,
1644- $ destination ,
1645- $ this ->getStepLineRef (),
1646- $ headers ,
1647- $ this ->getDavPathVersion (),
1648- $ noOfChunks
1649- );
1650- $ this ->lastUploadDeleteTime = \time ();
1651- } catch (BadResponseException $ e ) {
1652- // 4xx and 5xx responses cause an exception
1653- $ this ->response = $ e ->getResponse ();
1636+ ): ResponseInterface {
1637+ $ doChunkUpload = true ;
1638+ if ($ noOfChunks <= 0 ) {
1639+ $ doChunkUpload = false ;
16541640 }
1641+
1642+ $ this ->pauseUploadDelete ();
1643+ $ response = UploadHelper::upload (
1644+ $ this ->getBaseUrl (),
1645+ $ this ->getActualUsername ($ user ),
1646+ $ this ->getUserPassword ($ user ),
1647+ $ source ,
1648+ $ destination ,
1649+ $ this ->getStepLineRef (),
1650+ $ headers ,
1651+ $ this ->getDavPathVersion (),
1652+ $ doChunkUpload ,
1653+ $ noOfChunks ,
1654+ );
1655+ $ this ->lastUploadDeleteTime = \time ();
1656+ return $ response ;
16551657 }
16561658
16571659 /**
@@ -1662,7 +1664,7 @@ public function uploadFileWithHeaders(
16621664 * @param boolean $async
16631665 * @param array|null $headers
16641666 *
1665- * @return void
1667+ * @return ResponseInterface
16661668 */
16671669 public function userUploadsAFileInChunk (
16681670 string $ user ,
@@ -1671,7 +1673,7 @@ public function userUploadsAFileInChunk(
16711673 int $ noOfChunks = 2 ,
16721674 bool $ async = false ,
16731675 ?array $ headers = []
1674- ):void {
1676+ ): ResponseInterface {
16751677 $ user = $ this ->getActualUsername ($ user );
16761678 Assert::assertGreaterThan (
16771679 0 ,
@@ -1682,46 +1684,13 @@ public function userUploadsAFileInChunk(
16821684 if ($ async === true ) {
16831685 $ headers ['OC-LazyOps ' ] = 'true ' ;
16841686 }
1685- $ this ->uploadFileWithHeaders (
1687+ return $ this ->uploadFileWithHeaders (
16861688 $ user ,
16871689 $ this ->acceptanceTestsDirLocation () . $ source ,
16881690 $ destination ,
16891691 $ headers ,
16901692 $ noOfChunks
16911693 );
1692- $ this ->pushToLastStatusCodesArrays ();
1693- }
1694-
1695- /**
1696- * Uploading with old/new DAV and chunked/non-chunked.
1697- * Except do not do the new-DAV-new-chunking combination. That is not being
1698- * supported on all implementations.
1699- *
1700- * @When user :user uploads file :source to filenames based on :destination with all mechanisms using the WebDAV API
1701- *
1702- * @param string $user
1703- * @param string $source
1704- * @param string $destination
1705- *
1706- * @return void
1707- * @throws Exception
1708- * @throws GuzzleException
1709- */
1710- public function userUploadsAFileToWithAllMechanismsExceptNewChunking (
1711- string $ user ,
1712- string $ source ,
1713- string $ destination
1714- ):void {
1715- $ user = $ this ->getActualUsername ($ user );
1716- $ this ->uploadResponses = UploadHelper::uploadWithAllMechanisms (
1717- $ this ->getBaseUrl (),
1718- $ this ->getActualUsername ($ user ),
1719- $ this ->getUserPassword ($ user ),
1720- $ this ->acceptanceTestsDirLocation () . $ source ,
1721- $ destination ,
1722- $ this ->getStepLineRef (),
1723- false ,
1724- );
17251694 }
17261695
17271696 /**
@@ -1741,24 +1710,9 @@ public function userUploadsAFileToWithChunks(
17411710 string $ destination ,
17421711 int $ noOfChunks = 2
17431712 ):void {
1744- $ this ->userUploadsAFileInChunk ($ user , $ source , $ destination , $ noOfChunks );
1745- }
1746-
1747- /**
1748- * @Then /^the HTTP status code of all upload responses should be "([^"]*)"$/
1749- *
1750- * @param int $statusCode
1751- *
1752- * @return void
1753- */
1754- public function theHTTPStatusCodeOfAllUploadResponsesShouldBe (int $ statusCode ):void {
1755- foreach ($ this ->uploadResponses as $ response ) {
1756- Assert::assertEquals (
1757- $ statusCode ,
1758- $ response ->getStatusCode (),
1759- 'Response did not return expected status code '
1760- );
1761- }
1713+ $ response = $ this ->userUploadsAFileInChunk ($ user , $ source , $ destination , $ noOfChunks );
1714+ $ this ->setResponse ($ response );
1715+ $ this ->pushToLastStatusCodesArrays ();
17621716 }
17631717
17641718 /**
@@ -1950,32 +1904,6 @@ public function theUserShouldNotBeAbleToUploadFileTo(string $user, string $sourc
19501904 }
19511905 }
19521906
1953- /**
1954- * @Then /^the HTTP status code of all upload responses should be between "(\d+)" and "(\d+)"$/
1955- *
1956- * @param int $minStatusCode
1957- * @param int $maxStatusCode
1958- *
1959- * @return void
1960- */
1961- public function theHTTPStatusCodeOfAllUploadResponsesShouldBeBetween (
1962- int $ minStatusCode ,
1963- int $ maxStatusCode
1964- ):void {
1965- foreach ($ this ->uploadResponses as $ response ) {
1966- Assert::assertGreaterThanOrEqual (
1967- $ minStatusCode ,
1968- $ response ->getStatusCode (),
1969- 'Response did not return expected status code '
1970- );
1971- Assert::assertLessThanOrEqual (
1972- $ maxStatusCode ,
1973- $ response ->getStatusCode (),
1974- 'Response did not return expected status code '
1975- );
1976- }
1977- }
1978-
19791907 /**
19801908 * @param string $user
19811909 * @param string $destination
@@ -2193,6 +2121,7 @@ public function userUploadsFileToWithMtimeUsingTheWebdavApi(
21932121 $ this ->getStepLineRef (),
21942122 ["X-OC-Mtime " => $ mtime ],
21952123 $ this ->getDavPathVersion (),
2124+ false ,
21962125 1 ,
21972126 $ isGivenStep
21982127 );
@@ -2227,6 +2156,7 @@ public function userHasUploadedFileToWithMtimeUsingTheWebdavApi(
22272156 $ this ->getStepLineRef (),
22282157 ["X-OC-Mtime " => $ mtime ],
22292158 $ this ->getDavPathVersion (),
2159+ false ,
22302160 1 ,
22312161 true
22322162 );
0 commit comments