Ejemplo n.º 1
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage simulated exception
  */
 public function testIsOwnCloudServerFail()
 {
     $server = 'server1';
     $this->httpClientService->expects($this->once())->method('newClient')->willReturn($this->httpClient);
     $this->httpClient->expects($this->once())->method('get')->with($server . '/status.php')->willReturnCallback(function () {
         throw new \Exception('simulated exception');
     });
     $this->trustedServers->isOwnCloudServer($server);
 }
Ejemplo n.º 2
0
 /**
  * check if the server should be added to the list of trusted servers or not
  *
  * @param string $url
  * @return bool
  * @throws HintException
  */
 protected function checkServer($url)
 {
     if ($this->trustedServers->isTrustedServer($url) === true) {
         $message = 'Server is already in the list of trusted servers.';
         $hint = $this->l->t('Server is already in the list of trusted servers.');
         throw new HintException($message, $hint);
     }
     if ($this->trustedServers->isOwnCloudServer($url) === false) {
         $message = 'No ownCloud server found';
         $hint = $this->l->t('No ownCloud server found');
         throw new HintException($message, $hint);
     }
     return true;
 }