@@ -52,6 +52,30 @@ public function testAfterCreateCollection()
5252 $ this ->assertEquals ($ newPath , $ this ->tempPath );
5353 }
5454
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+
5579 public function afterHandler ($ path )
5680 {
5781 $ this ->tempPath = $ path ;
@@ -91,6 +115,32 @@ public function testBeforeBindCancel()
91115 $ this ->assertEquals (500 , $ this ->server ->httpResponse ->getStatus ());
92116 }
93117
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+
94144 public function beforeBindCancelHandler ($ path )
95145 {
96146 return false ;
0 commit comments