/** * Test getting the storage info excluding extra mount points * when user has no quota set, even when quota ext storage option * was set */ function testGetStorageInfoIncludingExtStorageWithNoUserQuota() { $homeStorage = $this->getStorageMock(12); \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); $homeStorage->file_put_contents('test.txt', '01234'); $extStorage = new \OC\Files\Storage\Temporary(array()); $extStorage->file_put_contents('extfile.txt', 'abcdefghijklmnopq'); $extStorage->getScanner()->scan(''); // update root size \OC\Files\Filesystem::mount($extStorage, array(), '/' . $this->user . '/files/ext'); $config = \OC::$server->getConfig(); $oldConfig = $config->getSystemValue('quota_include_external_storage', false); $config->setSystemValue('quota_include_external_storage', 'true'); $storageInfo = \OC_Helper::getStorageInfo(''); $this->assertEquals(12, $storageInfo['free']); $this->assertEquals(5, $storageInfo['used']); $this->assertEquals(17, $storageInfo['total']); $config->setSystemValue('quota_include_external_storage', $oldConfig); }
/** * @param bool $scan * @return \OC\Files\Storage\Storage */ private function getTestStorage($scan = true) { $storage = new \OC\Files\Storage\Temporary(array()); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); $storage->mkdir('folder'); $storage->file_put_contents('foo.txt', $textData); $storage->file_put_contents('foo.png', $imgData); $storage->file_put_contents('folder/bar.txt', $textData); $storage->file_put_contents('folder/bar2.txt', $textData); if ($scan) { $scanner = $storage->getScanner(); $scanner->scan(''); } $this->storages[] = $storage; return $storage; }