11
11
12
12
trait WebDav {
13
13
/** @var string */
14
- private $ davPath = " remote.php/webdav " ;
14
+ private $ davPath = ' remote.php/webdav ' ;
15
15
/** @var boolean */
16
16
private $ usingOldDavPath = true ;
17
17
/** @var array map with user as key and another map as value, which has path as key and etag as value */
@@ -30,15 +30,15 @@ public function usingDavPath($davPath) {
30
30
* @Given /^using old dav path$/
31
31
*/
32
32
public function usingOldDavPath () {
33
- $ this ->davPath = " remote.php/webdav " ;
33
+ $ this ->davPath = ' remote.php/webdav ' ;
34
34
$ this ->usingOldDavPath = true ;
35
35
}
36
36
37
37
/**
38
38
* @Given /^using new dav path$/
39
39
*/
40
40
public function usingNewDavPath () {
41
- $ this ->davPath = " remote.php/dav " ;
41
+ $ this ->davPath = ' remote.php/dav ' ;
42
42
$ this ->usingOldDavPath = false ;
43
43
}
44
44
@@ -50,10 +50,10 @@ public function getDavFilesPath($user) {
50
50
}
51
51
}
52
52
53
- public function makeDavRequest ($ user , $ method , $ path , $ headers , $ body = null , $ type = " files " ) {
54
- if ($ type === " files " ) {
53
+ public function makeDavRequest ($ user , $ method , $ path , $ headers , $ body = null , $ type = ' files ' ) {
54
+ if ($ type === ' files ' ) {
55
55
$ fullUrl = $ this ->baseUrl . $ this ->getDavFilesPath ($ user ) . "$ path " ;
56
- } elseif ($ type === " uploads " ) {
56
+ } elseif ($ type === ' uploads ' ) {
57
57
$ fullUrl = $ this ->baseUrl . $ this ->davPath . "$ path " ;
58
58
} else {
59
59
$ fullUrl = $ this ->baseUrl . $ this ->davPath . '/ ' . $ type . "$ path " ;
@@ -80,7 +80,7 @@ public function makeDavRequest($user, $method, $path, $headers, $body = null, $t
80
80
public function userMovedFile ($ user , $ entry , $ fileSource , $ fileDestination ) {
81
81
$ fullUrl = $ this ->baseUrl . $ this ->getDavFilesPath ($ user );
82
82
$ headers ['Destination ' ] = $ fullUrl . $ fileDestination ;
83
- $ this ->response = $ this ->makeDavRequest ($ user , " MOVE " , $ fileSource , $ headers );
83
+ $ this ->response = $ this ->makeDavRequest ($ user , ' MOVE ' , $ fileSource , $ headers );
84
84
Assert::assertEquals (201 , $ this ->response ->getStatusCode ());
85
85
}
86
86
@@ -94,7 +94,7 @@ public function userMovesFile($user, $entry, $fileSource, $fileDestination) {
94
94
$ fullUrl = $ this ->baseUrl . $ this ->getDavFilesPath ($ user );
95
95
$ headers ['Destination ' ] = $ fullUrl . $ fileDestination ;
96
96
try {
97
- $ this ->response = $ this ->makeDavRequest ($ user , " MOVE " , $ fileSource , $ headers );
97
+ $ this ->response = $ this ->makeDavRequest ($ user , ' MOVE ' , $ fileSource , $ headers );
98
98
} catch (\GuzzleHttp \Exception \ClientException $ e ) {
99
99
$ this ->response = $ e ->getResponse ();
100
100
}
@@ -126,7 +126,7 @@ public function userCopiesFileTo($user, $entry, $fileSource, $fileDestination) {
126
126
public function downloadFileWithRange ($ fileSource , $ range ) {
127
127
$ headers ['Range ' ] = $ range ;
128
128
try {
129
- $ this ->response = $ this ->makeDavRequest ($ this ->currentUser , " GET " , $ fileSource , $ headers );
129
+ $ this ->response = $ this ->makeDavRequest ($ this ->currentUser , ' GET ' , $ fileSource , $ headers );
130
130
} catch (\GuzzleHttp \Exception \ClientException $ e ) {
131
131
$ this ->response = $ e ->getResponse ();
132
132
}
@@ -138,16 +138,16 @@ public function downloadFileWithRange($fileSource, $range) {
138
138
*/
139
139
public function downloadPublicFileWithRange ($ range ) {
140
140
$ token = $ this ->lastShareData ->data ->token ;
141
- $ fullUrl = $ this ->baseUrl . " public.php/webdav " ;
141
+ $ fullUrl = $ this ->baseUrl . ' public.php/webdav ' ;
142
142
143
143
$ client = new GClient ();
144
144
$ options = [];
145
- $ options ['auth ' ] = [$ token , "" ];
145
+ $ options ['auth ' ] = [$ token , '' ];
146
146
$ options ['headers ' ] = [
147
147
'Range ' => $ range
148
148
];
149
149
150
- $ this ->response = $ client ->request (" GET " , $ fullUrl , $ options );
150
+ $ this ->response = $ client ->request (' GET ' , $ fullUrl , $ options );
151
151
}
152
152
153
153
/**
@@ -156,17 +156,17 @@ public function downloadPublicFileWithRange($range) {
156
156
*/
157
157
public function downloadPublicFileInsideAFolderWithRange ($ path , $ range ) {
158
158
$ token = $ this ->lastShareData ->data ->token ;
159
- $ fullUrl = $ this ->baseUrl . " public.php/webdav " . "$ path " ;
159
+ $ fullUrl = $ this ->baseUrl . ' public.php/webdav ' . "$ path " ;
160
160
161
161
$ client = new GClient ();
162
162
$ options = [
163
163
'headers ' => [
164
164
'Range ' => $ range
165
165
]
166
166
];
167
- $ options ['auth ' ] = [$ token , "" ];
167
+ $ options ['auth ' ] = [$ token , '' ];
168
168
169
- $ this ->response = $ client ->request (" GET " , $ fullUrl , $ options );
169
+ $ this ->response = $ client ->request (' GET ' , $ fullUrl , $ options );
170
170
}
171
171
172
172
/**
@@ -314,7 +314,7 @@ public function theSingleResponseShouldContainAPropertyWithValue($key, $expected
314
314
public function theResponseShouldContainAShareTypesPropertyWith ($ table ) {
315
315
$ keys = $ this ->response ;
316
316
if (!array_key_exists ('{http://owncloud.org/ns}share-types ' , $ keys )) {
317
- throw new \Exception (" Cannot find property \ "{http://owncloud.org/ns}share-types \"" );
317
+ throw new \Exception (' Cannot find property "{http://owncloud.org/ns}share-types" ' );
318
318
}
319
319
320
320
$ foundTypes = [];
@@ -481,7 +481,7 @@ public function searchFile(string $user, ?string $properties = null, ?string $sc
481
481
</d:searchrequest> ' ;
482
482
483
483
try {
484
- $ this ->response = $ this ->makeDavRequest ($ user , " SEARCH " , '' , [
484
+ $ this ->response = $ this ->makeDavRequest ($ user , ' SEARCH ' , '' , [
485
485
'Content-Type ' => 'text/xml '
486
486
], $ body , '' );
487
487
} catch (\GuzzleHttp \Exception \ServerException $ e ) {
@@ -555,9 +555,9 @@ public function checkElementList($user, $expectedElements) {
555
555
$ elementRows = $ expectedElements ->getRows ();
556
556
$ elementsSimplified = $ this ->simplifyArray ($ elementRows );
557
557
foreach ($ elementsSimplified as $ expectedElement ) {
558
- $ webdavPath = " / " . $ this ->getDavFilesPath ($ user ) . $ expectedElement ;
558
+ $ webdavPath = ' / ' . $ this ->getDavFilesPath ($ user ) . $ expectedElement ;
559
559
if (!array_key_exists ($ webdavPath , $ elementList )) {
560
- Assert::fail ("$ webdavPath " . " is not in propfind answer " );
560
+ Assert::fail ("$ webdavPath " . ' is not in propfind answer ' );
561
561
}
562
562
}
563
563
}
@@ -572,7 +572,7 @@ public function checkElementList($user, $expectedElements) {
572
572
public function userUploadsAFileTo ($ user , $ source , $ destination ) {
573
573
$ file = \GuzzleHttp \Psr7 \Utils::streamFor (fopen ($ source , 'r ' ));
574
574
try {
575
- $ this ->response = $ this ->makeDavRequest ($ user , " PUT " , $ destination , [], $ file );
575
+ $ this ->response = $ this ->makeDavRequest ($ user , ' PUT ' , $ destination , [], $ file );
576
576
} catch (\GuzzleHttp \Exception \ServerException $ e ) {
577
577
// 5xx responses cause a server exception
578
578
$ this ->response = $ e ->getResponse ();
@@ -589,11 +589,11 @@ public function userUploadsAFileTo($user, $source, $destination) {
589
589
* @param string $destination
590
590
*/
591
591
public function userAddsAFileTo ($ user , $ bytes , $ destination ) {
592
- $ filename = " filespecificSize.txt " ;
592
+ $ filename = ' filespecificSize.txt ' ;
593
593
$ this ->createFileSpecificSize ($ filename , $ bytes );
594
594
Assert::assertEquals (1 , file_exists ("work/ $ filename " ));
595
595
$ this ->userUploadsAFileTo ($ user , "work/ $ filename " , $ destination );
596
- $ this ->removeFile (" work/ " , $ filename );
596
+ $ this ->removeFile (' work/ ' , $ filename );
597
597
$ expectedElements = new \Behat \Gherkin \Node \TableNode ([["$ destination " ]]);
598
598
$ this ->checkElementList ($ user , $ expectedElements );
599
599
}
@@ -604,7 +604,7 @@ public function userAddsAFileTo($user, $bytes, $destination) {
604
604
public function userUploadsAFileWithContentTo ($ user , $ content , $ destination ) {
605
605
$ file = \GuzzleHttp \Psr7 \Utils::streamFor ($ content );
606
606
try {
607
- $ this ->response = $ this ->makeDavRequest ($ user , " PUT " , $ destination , [], $ file );
607
+ $ this ->response = $ this ->makeDavRequest ($ user , ' PUT ' , $ destination , [], $ file );
608
608
} catch (\GuzzleHttp \Exception \ServerException $ e ) {
609
609
// 5xx responses cause a server exception
610
610
$ this ->response = $ e ->getResponse ();
@@ -650,7 +650,7 @@ public function emptyTrashbin($user) {
650
650
public function userCreatedAFolder ($ user , $ destination ) {
651
651
try {
652
652
$ destination = '/ ' . ltrim ($ destination , '/ ' );
653
- $ this ->response = $ this ->makeDavRequest ($ user , " MKCOL " , $ destination , []);
653
+ $ this ->response = $ this ->makeDavRequest ($ user , ' MKCOL ' , $ destination , []);
654
654
} catch (\GuzzleHttp \Exception \ServerException $ e ) {
655
655
// 5xx responses cause a server exception
656
656
$ this ->response = $ e ->getResponse ();
@@ -672,7 +672,7 @@ public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $d
672
672
$ num -= 1 ;
673
673
$ data = \GuzzleHttp \Psr7 \Utils::streamFor ($ data );
674
674
$ file = $ destination . '-chunking-42- ' . $ total . '- ' . $ num ;
675
- $ this ->makeDavRequest ($ user , 'PUT ' , $ file , ['OC-Chunked ' => '1 ' ], $ data , " uploads " );
675
+ $ this ->makeDavRequest ($ user , 'PUT ' , $ file , ['OC-Chunked ' => '1 ' ], $ data , ' uploads ' );
676
676
}
677
677
678
678
/**
@@ -686,28 +686,28 @@ public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $d
686
686
* @param string $content3
687
687
*/
688
688
public function userUploadsBulkedFiles ($ user , $ name1 , $ content1 , $ name2 , $ content2 , $ name3 , $ content3 ) {
689
- $ boundary = " boundary_azertyuiop " ;
689
+ $ boundary = ' boundary_azertyuiop ' ;
690
690
691
- $ body = "" ;
691
+ $ body = '' ;
692
692
$ body .= '-- ' .$ boundary ."\r\n" ;
693
- $ body .= " X-File-Path: " .$ name1 ."\r\n" ;
693
+ $ body .= ' X-File-Path: ' .$ name1 ."\r\n" ;
694
694
$ body .= "X-File-MD5: f6a6263167c92de8644ac998b3c4e4d1 \r\n" ;
695
695
$ body .= "X-OC-Mtime: 1111111111 \r\n" ;
696
- $ body .= " Content-Length: " .strlen ($ content1 )."\r\n" ;
696
+ $ body .= ' Content-Length: ' .strlen ($ content1 )."\r\n" ;
697
697
$ body .= "\r\n" ;
698
698
$ body .= $ content1 ."\r\n" ;
699
699
$ body .= '-- ' .$ boundary ."\r\n" ;
700
- $ body .= " X-File-Path: " .$ name2 ."\r\n" ;
700
+ $ body .= ' X-File-Path: ' .$ name2 ."\r\n" ;
701
701
$ body .= "X-File-MD5: 87c7d4068be07d390a1fffd21bf1e944 \r\n" ;
702
702
$ body .= "X-OC-Mtime: 2222222222 \r\n" ;
703
- $ body .= " Content-Length: " .strlen ($ content2 )."\r\n" ;
703
+ $ body .= ' Content-Length: ' .strlen ($ content2 )."\r\n" ;
704
704
$ body .= "\r\n" ;
705
705
$ body .= $ content2 ."\r\n" ;
706
706
$ body .= '-- ' .$ boundary ."\r\n" ;
707
- $ body .= " X-File-Path: " .$ name3 ."\r\n" ;
707
+ $ body .= ' X-File-Path: ' .$ name3 ."\r\n" ;
708
708
$ body .= "X-File-MD5: e86a1cf0678099986a901c79086f5617 \r\n" ;
709
709
$ body .= "X-File-Mtime: 3333333333 \r\n" ;
710
- $ body .= " Content-Length: " .strlen ($ content3 )."\r\n" ;
710
+ $ body .= ' Content-Length: ' .strlen ($ content3 )."\r\n" ;
711
711
$ body .= "\r\n" ;
712
712
$ body .= $ content3 ."\r\n" ;
713
713
$ body .= '-- ' .$ boundary ."-- \r\n" ;
@@ -726,15 +726,15 @@ public function userUploadsBulkedFiles($user, $name1, $content1, $name2, $conten
726
726
'body ' => $ body
727
727
];
728
728
729
- return $ client ->request (" POST " , $ this ->baseUrl . " remote.php/dav/bulk " , $ options );
729
+ return $ client ->request (' POST ' , $ this ->baseUrl . ' remote.php/dav/bulk ' , $ options );
730
730
}
731
731
732
732
/**
733
733
* @Given user :user creates a new chunking upload with id :id
734
734
*/
735
735
public function userCreatesANewChunkingUploadWithId ($ user , $ id ) {
736
736
$ destination = '/uploads/ ' . $ user . '/ ' . $ id ;
737
- $ this ->makeDavRequest ($ user , 'MKCOL ' , $ destination , [], null , " uploads " );
737
+ $ this ->makeDavRequest ($ user , 'MKCOL ' , $ destination , [], null , ' uploads ' );
738
738
}
739
739
740
740
/**
@@ -743,7 +743,7 @@ public function userCreatesANewChunkingUploadWithId($user, $id) {
743
743
public function userUploadsNewChunkFileOfWithToId ($ user , $ num , $ data , $ id ) {
744
744
$ data = \GuzzleHttp \Psr7 \Utils::streamFor ($ data );
745
745
$ destination = '/uploads/ ' . $ user . '/ ' . $ id . '/ ' . $ num ;
746
- $ this ->makeDavRequest ($ user , 'PUT ' , $ destination , [], $ data , " uploads " );
746
+ $ this ->makeDavRequest ($ user , 'PUT ' , $ destination , [], $ data , ' uploads ' );
747
747
}
748
748
749
749
/**
@@ -754,7 +754,7 @@ public function userMovesNewChunkFileWithIdToMychunkedfile($user, $id, $dest) {
754
754
$ destination = $ this ->baseUrl . $ this ->getDavFilesPath ($ user ) . $ dest ;
755
755
$ this ->makeDavRequest ($ user , 'MOVE ' , $ source , [
756
756
'Destination ' => $ destination
757
- ], null , " uploads " );
757
+ ], null , ' uploads ' );
758
758
}
759
759
760
760
/**
@@ -768,7 +768,7 @@ public function userMovesNewChunkFileWithIdToMychunkedfileWithSize($user, $id, $
768
768
$ this ->response = $ this ->makeDavRequest ($ user , 'MOVE ' , $ source , [
769
769
'Destination ' => $ destination ,
770
770
'OC-Total-Length ' => $ size
771
- ], null , " uploads " );
771
+ ], null , ' uploads ' );
772
772
} catch (\GuzzleHttp \Exception \BadResponseException $ ex ) {
773
773
$ this ->response = $ ex ->getResponse ();
774
774
}
@@ -906,9 +906,9 @@ public function checkFavoritedElements($user, $folder, $expectedElements) {
906
906
$ elementRows = $ expectedElements ->getRows ();
907
907
$ elementsSimplified = $ this ->simplifyArray ($ elementRows );
908
908
foreach ($ elementsSimplified as $ expectedElement ) {
909
- $ webdavPath = " / " . $ this ->getDavFilesPath ($ user ) . $ expectedElement ;
909
+ $ webdavPath = ' / ' . $ this ->getDavFilesPath ($ user ) . $ expectedElement ;
910
910
if (!array_key_exists ($ webdavPath , $ elementList )) {
911
- Assert::fail ("$ webdavPath " . " is not in report answer " );
911
+ Assert::fail ("$ webdavPath " . ' is not in report answer ' );
912
912
}
913
913
}
914
914
}
@@ -923,12 +923,12 @@ public function userDeletesEverythingInFolder($user, $folder) {
923
923
$ elementList = $ this ->listFolder ($ user , $ folder , 1 );
924
924
$ elementListKeys = array_keys ($ elementList );
925
925
array_shift ($ elementListKeys );
926
- $ davPrefix = " / " . $ this ->getDavFilesPath ($ user );
926
+ $ davPrefix = ' / ' . $ this ->getDavFilesPath ($ user );
927
927
foreach ($ elementListKeys as $ element ) {
928
928
if (substr ($ element , 0 , strlen ($ davPrefix )) == $ davPrefix ) {
929
929
$ element = substr ($ element , strlen ($ davPrefix ));
930
930
}
931
- $ this ->userDeletesFile ($ user , " element " , $ element );
931
+ $ this ->userDeletesFile ($ user , ' element ' , $ element );
932
932
}
933
933
}
934
934
@@ -963,7 +963,7 @@ public function userSeesNoFilesInTheTrashbin($user) {
963
963
* @return int
964
964
*/
965
965
private function getFileIdForPath ($ user , $ path ) {
966
- $ propertiesTable = new \Behat \Gherkin \Node \TableNode ([[" {http://owncloud.org/ns}fileid " ]]);
966
+ $ propertiesTable = new \Behat \Gherkin \Node \TableNode ([[' {http://owncloud.org/ns}fileid ' ]]);
967
967
$ this ->asGetsPropertiesOfFolderWith ($ user , 'file ' , $ path , $ propertiesTable );
968
968
return (int )$ this ->response ['{http://owncloud.org/ns}fileid ' ];
969
969
}
0 commit comments