Пример #1
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());
     }
 }
Пример #2
0
 public function testGetStorage()
 {
     $storageConfig = new StorageConfig(1);
     $storageConfig->setMountPoint('test');
     $storageConfig->setBackendClass('\\OC\\Files\\Storage\\SMB');
     $storageConfig->setBackendOptions(['user' => 'test', 'password', 'password123']);
     $storageConfig->setMountOptions(['priority' => false]);
     $this->service->expects($this->once())->method('getStorage')->with(1)->will($this->returnValue($storageConfig));
     $response = $this->controller->show(1);
     $this->assertEquals(Http::STATUS_OK, $response->getStatus());
     $this->assertEquals($storageConfig, $response->getData());
 }