@@ -52,6 +52,30 @@ public function testAfterCreateCollection()
52
52
$ this ->assertEquals ($ newPath , $ this ->tempPath );
53
53
}
54
54
55
+ public function testAfterCopy ()
56
+ {
57
+ $ tmpPath1 = '' ;
58
+ $ tmpPath2 = '' ;
59
+ $ this ->server ->on ('afterCopy ' , function ($ source , $ destination ) use (&$ tmpPath1 , &$ tmpPath2 ) {
60
+ $ tmpPath1 = $ source ;
61
+ $ tmpPath2 = $ destination ;
62
+ });
63
+
64
+ $ oldPath = '/oldCopy.txt ' ;
65
+ $ newPath = '/newCopy.txt ' ;
66
+
67
+ $ this ->server ->createFile ($ oldPath , 'body ' );
68
+ $ request = new HTTP \Request ('COPY ' , $ oldPath , [
69
+ 'Destination ' => $ newPath ,
70
+ ]);
71
+ $ this ->server ->httpRequest = $ request ;
72
+
73
+ $ this ->server ->exec ();
74
+ $ this ->assertEquals (201 , $ this ->server ->httpResponse ->getStatus ());
75
+ $ this ->assertEquals (trim ($ oldPath , '/ ' ), $ tmpPath1 );
76
+ $ this ->assertEquals (trim ($ newPath , '/ ' ), $ tmpPath2 );
77
+ }
78
+
55
79
public function afterHandler ($ path )
56
80
{
57
81
$ this ->tempPath = $ path ;
@@ -91,6 +115,32 @@ public function testBeforeBindCancel()
91
115
$ this ->assertEquals (500 , $ this ->server ->httpResponse ->getStatus ());
92
116
}
93
117
118
+ public function testBeforeCopyCancel ()
119
+ {
120
+ $ tmpPath1 = '' ;
121
+ $ tmpPath2 = '' ;
122
+ $ this ->server ->on ('beforeCopy ' , function ($ source , $ destination ) use (&$ tmpPath1 , &$ tmpPath2 ) {
123
+ $ tmpPath1 = $ source ;
124
+ $ tmpPath2 = $ destination ;
125
+
126
+ return false ;
127
+ });
128
+
129
+ $ oldPath = '/oldCopy.txt ' ;
130
+ $ newPath = '/newCopy.txt ' ;
131
+
132
+ $ this ->server ->createFile ($ oldPath , 'body ' );
133
+ $ request = new HTTP \Request ('COPY ' , $ oldPath , [
134
+ 'Destination ' => $ newPath ,
135
+ ]);
136
+ $ this ->server ->httpRequest = $ request ;
137
+
138
+ $ this ->server ->exec ();
139
+ $ this ->assertEquals (500 , $ this ->server ->httpResponse ->getStatus ());
140
+ $ this ->assertEquals (trim ($ oldPath , '/ ' ), $ tmpPath1 );
141
+ $ this ->assertEquals (trim ($ newPath , '/ ' ), $ tmpPath2 );
142
+ }
143
+
94
144
public function beforeBindCancelHandler ($ path )
95
145
{
96
146
return false ;
0 commit comments