diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-02-10 17:50:04 +0400 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-02-21 18:53:11 +0400 |
commit | e903c8b57b9e6008316c5da88c730da9b1590bd9 (patch) | |
tree | a97f5e9bd73a2a8bf946e453d7fcf7bfab7a58ff /apps/files_sharing | |
parent | 210832ddf149ac893720d5ee2ad9544fca97a79b (diff) |
fix test so that it doesn't depend on the array order
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/tests/cache.php | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php index 5e61eb86dd7..a75e1860527 100644 --- a/apps/files_sharing/tests/cache.php +++ b/apps/files_sharing/tests/cache.php @@ -145,7 +145,6 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base { } function testGetFolderContentsInSubdir() { - //$results = $this->sharedStorage->getCache()->getFolderContents('shareddir'); $results = $this->user2View->getDirectoryContent('/Shared/shareddir'); $this->verifyFiles( @@ -183,7 +182,6 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base { self::loginHelper(self::TEST_FILES_SHARING_API_USER3); $thirdView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files'); - //list($this->sharedStorage, $internalPath) = $thirdView->resolvePath('files/Shared'); $results = $thirdView->getDirectoryContent('/Shared/subdir'); $this->verifyFiles( @@ -191,21 +189,18 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base { array( 'name' => 'another too.txt', 'path' => 'files/container/shareddir/subdir/another too.txt', - //'path' => '/subdir/another too.txt', 'mimetype' => 'text/plain', 'usersPath' => 'files/Shared/subdir/another too.txt' ), array( 'name' => 'another.txt', 'path' => 'files/container/shareddir/subdir/another.txt', - //'path' => '/subdir/another.txt', 'mimetype' => 'text/plain', 'usersPath' => 'files/Shared/subdir/another.txt' ), array( 'name' => 'not a text file.xml', 'path' => 'files/container/shareddir/subdir/not a text file.xml', - //'path' => '/subdir/not a text file.xml', 'mimetype' => 'application/xml', 'usersPath' => 'files/Shared/subdir/not a text file.xml' ), @@ -220,19 +215,35 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base { } /** - * Checks that all provided attributes exist in the files list, - * only the values provided in $examples will be used to check against - * the file list. The files order also needs to be the same. + * Check if 'results' contains the expected 'examples' only. * * @param array $examples array of example files - * @param array $files array of files + * @param array $results array of files */ - private function verifyFiles($examples, $files) { - $this->assertEquals(count($examples), count($files)); - foreach ($files as $i => $file) { - foreach ($examples[$i] as $key => $value) { - $this->assertEquals($value, $file[$key]); + private function verifyFiles($examples, $results) { + $this->assertEquals(count($examples), count($results)); + + foreach ($examples as $example) { + foreach ($results as $key => $result) { + if ($result['name'] === $example['name']) { + $this->verifyKeys($example, $result); + unset($results[$key]); + break; + } } } + $this->assertTrue(empty($results)); } + + /** + * @brief verify if each value from the result matches the expected result + * @param array $example array with the expected results + * @param array $result array with the results + */ + private function verifyKeys($example, $result) { + foreach ($example as $key => $value) { + $this->assertEquals($value, $result[$key]); + } + } + } |