@@ -105,6 +105,7 @@ public function testNotifyGetChanges() {
105105 $ this ->instance ->unlink ('/renamed.txt ' );
106106 sleep (1 ); //time for all changes to be processed
107107
108+ /** @var IChange[] $changes */
108109 $ changes = [];
109110 $ count = 0 ;
110111 // wait up to 10 seconds for incoming changes
@@ -115,14 +116,23 @@ public function testNotifyGetChanges() {
115116 }
116117 $ notifyHandler ->stop ();
117118
118- $ expected = [
119- new Change (IChange::ADDED , 'newfile.txt ' ),
120- new RenameChange (IChange::RENAMED , 'newfile.txt ' , 'renamed.txt ' ),
121- new Change (IChange::REMOVED , 'renamed.txt ' )
122- ];
119+ // depending on the server environment, the initial create might be detected as a change instead
120+ if ($ changes [0 ]->getType () === IChange::MODIFIED ) {
121+ $ expected = [
122+ new Change (IChange::MODIFIED , 'newfile.txt ' ),
123+ new RenameChange (IChange::RENAMED , 'newfile.txt ' , 'renamed.txt ' ),
124+ new Change (IChange::REMOVED , 'renamed.txt ' )
125+ ];
126+ } else {
127+ $ expected = [
128+ new Change (IChange::ADDED , 'newfile.txt ' ),
129+ new RenameChange (IChange::RENAMED , 'newfile.txt ' , 'renamed.txt ' ),
130+ new Change (IChange::REMOVED , 'renamed.txt ' )
131+ ];
132+ }
123133
124134 foreach ($ expected as $ expectedChange ) {
125- $ this ->assertTrue (in_array ($ expectedChange , $ changes ), ' Actual changes are:' . PHP_EOL . print_r ($ changes , true ) . PHP_EOL . 'Expected to find: ' . PHP_EOL . print_r ($ expectedChange , true ));
135+ $ this ->assertTrue (in_array ($ expectedChange , $ changes ), " Expected changes are:\n" . print_r ($ expected , true ) . PHP_EOL . 'Expected to find: ' . PHP_EOL . print_r ($ expectedChange, true ) . "\n Got: \n" . print_r ( $ changes , true ));
126136 }
127137 }
128138
@@ -141,7 +151,12 @@ public function testNotifyListen() {
141151 return false ;//stop listening
142152 });
143153
144- $ this ->assertEquals (new Change (IChange::ADDED , 'newfile.txt ' ), $ result );
154+ // depending on the server environment, the initial create might be detected as a change instead
155+ if ($ result ->getType () === IChange::ADDED ) {
156+ $ this ->assertEquals (new Change (IChange::ADDED , 'newfile.txt ' ), $ result );
157+ } else {
158+ $ this ->assertEquals (new Change (IChange::MODIFIED , 'newfile.txt ' ), $ result );
159+ }
145160 }
146161
147162 public function testRenameRoot () {
0 commit comments