public function testAddOrUpdateStorageInvalidBackend()
 {
     $this->service->expects($this->never())->method('addStorage');
     $this->service->expects($this->never())->method('updateStorage');
     $response = $this->controller->create('mount', '\\OC\\Files\\Storage\\InvalidStorage', array(), [], [], [], null);
     $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
     $response = $this->controller->update(1, 'mount', '\\OC\\Files\\Storage\\InvalidStorage', array(), [], [], [], null);
     $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
 }
Esempio n. 2
0
 /**
  * @dataProvider validateStorageProvider
  */
 public function testValidateStorage($backendValidate, $authMechValidate, $expectSuccess)
 {
     $backend = $this->getBackendMock();
     $backend->method('validateStorage')->willReturn($backendValidate);
     $backend->method('isVisibleFor')->willReturn(true);
     $authMech = $this->getAuthMechMock();
     $authMech->method('validateStorage')->will($this->returnValue($authMechValidate));
     $storageConfig = new StorageConfig();
     $storageConfig->setMountPoint('mount');
     $storageConfig->setBackend($backend);
     $storageConfig->setAuthMechanism($authMech);
     $storageConfig->setBackendOptions([]);
     $this->service->expects($this->once())->method('createStorage')->will($this->returnValue($storageConfig));
     if ($expectSuccess) {
         $this->service->expects($this->once())->method('addStorage')->with($storageConfig)->will($this->returnValue($storageConfig));
     } else {
         $this->service->expects($this->never())->method('addStorage');
     }
     $response = $this->controller->create('mount', '\\OC\\Files\\Storage\\SMB', '\\OCA\\Files_External\\Lib\\Auth\\NullMechanism', array(), [], [], [], null);
     if ($expectSuccess) {
         $this->assertEquals(Http::STATUS_CREATED, $response->getStatus());
     } else {
         $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
     }
 }