diff options
author | Robin Appelman <robin@icewind.nl> | 2022-01-21 14:09:45 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-03-08 14:20:14 +0100 |
commit | d1c6e82d7752e7430ca2ccb79dd608233b91a6d1 (patch) | |
tree | 8b5a319927097f87f4e46a9ddade10267eb0da17 /apps | |
parent | ea8a774a0a2079a2ebe44e8d4a62162d80754e23 (diff) | |
download | nextcloud-server-d1c6e82d7752e7430ca2ccb79dd608233b91a6d1.tar.gz nextcloud-server-d1c6e82d7752e7430ca2ccb79dd608233b91a6d1.zip |
test: improve notify tests for smb
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/tests/Storage/SmbTest.php | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php index 30040e499c8..6d21f696683 100644 --- a/apps/files_external/tests/Storage/SmbTest.php +++ b/apps/files_external/tests/Storage/SmbTest.php @@ -105,6 +105,7 @@ class SmbTest extends \Test\Files\Storage\Storage { $this->instance->unlink('/renamed.txt'); sleep(1); //time for all changes to be processed + /** @var IChange[] $changes */ $changes = []; $count = 0; // wait up to 10 seconds for incoming changes @@ -115,14 +116,23 @@ class SmbTest extends \Test\Files\Storage\Storage { } $notifyHandler->stop(); - $expected = [ - new Change(IChange::ADDED, 'newfile.txt'), - new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'), - new Change(IChange::REMOVED, 'renamed.txt') - ]; + // depending on the server environment, the initial create might be detected as a change instead + if ($changes[0]->getType() === IChange::MODIFIED) { + $expected = [ + new Change(IChange::MODIFIED, 'newfile.txt'), + new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'), + new Change(IChange::REMOVED, 'renamed.txt') + ]; + } else { + $expected = [ + new Change(IChange::ADDED, 'newfile.txt'), + new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'), + new Change(IChange::REMOVED, 'renamed.txt') + ]; + } foreach ($expected as $expectedChange) { - $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)); + $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) . "\nGot:\n" . print_r($changes, true)); } } @@ -141,7 +151,12 @@ class SmbTest extends \Test\Files\Storage\Storage { return false;//stop listening }); - $this->assertEquals(new Change(IChange::ADDED, 'newfile.txt'), $result); + // depending on the server environment, the initial create might be detected as a change instead + if ($result->getType() === IChange::ADDED) { + $this->assertEquals(new Change(IChange::ADDED, 'newfile.txt'), $result); + } else { + $this->assertEquals(new Change(IChange::MODIFIED, 'newfile.txt'), $result); + } } public function testRenameRoot() { |