Exemple #1
0
 /**
  * @dataProvider deleteStorageDataProvider
  */
 public function testDeleteStorage($backendOptions, $rustyStorageId, $expectedCountAfterDeletion)
 {
     $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB');
     $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism');
     $storage = new StorageConfig(255);
     $storage->setMountPoint('mountpoint');
     $storage->setBackend($backend);
     $storage->setAuthMechanism($authMechanism);
     $storage->setBackendOptions($backendOptions);
     $newStorage = $this->service->addStorage($storage);
     $this->assertEquals(1, $newStorage->getId());
     // manually trigger storage entry because normally it happens on first
     // access, which isn't possible within this test
     $storageCache = new \OC\Files\Cache\Storage($rustyStorageId);
     // get numeric id for later check
     $numericId = $storageCache->getNumericId();
     $newStorage = $this->service->removeStorage(1);
     $caught = false;
     try {
         $this->service->getStorage(1);
     } catch (NotFoundException $e) {
         $caught = true;
     }
     $this->assertTrue($caught);
     // storage id was removed from oc_storages
     $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
     $storageCheckQuery = $qb->select('*')->from('storages')->where($qb->expr()->eq('numeric_id', $qb->expr()->literal($numericId)));
     $this->assertCount($expectedCountAfterDeletion, $storageCheckQuery->execute()->fetchAll());
 }
 public function testDeleteStorage()
 {
     $storage = new StorageConfig(255);
     $storage->setMountPoint('mountpoint');
     $storage->setBackendClass('\\OC\\Files\\Storage\\SMB');
     $storage->setBackendOptions(['password' => 'testPassword']);
     $newStorage = $this->service->addStorage($storage);
     $this->assertEquals(1, $newStorage->getId());
     $newStorage = $this->service->removeStorage(1);
     $caught = false;
     try {
         $this->service->getStorage(1);
     } catch (NotFoundException $e) {
         $caught = true;
     }
     $this->assertTrue($caught);
 }
 public function testDeleteStorage()
 {
     $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB');
     $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism');
     $storage = new StorageConfig(255);
     $storage->setMountPoint('mountpoint');
     $storage->setBackend($backend);
     $storage->setAuthMechanism($authMechanism);
     $storage->setBackendOptions(['password' => 'testPassword']);
     $newStorage = $this->service->addStorage($storage);
     $this->assertEquals(1, $newStorage->getId());
     $newStorage = $this->service->removeStorage(1);
     $caught = false;
     try {
         $this->service->getStorage(1);
     } catch (NotFoundException $e) {
         $caught = true;
     }
     $this->assertTrue($caught);
 }