Ejemplo n.º 1
0
 public function itSetsIdOfNewServerOnSave()
 {
     $new_server = new Git_RemoteServer_GerritServer(0, $this->host, $this->ssh_port, $this->http_port, $this->login, $this->identity_file, $this->replication_key, $this->use_ssl, $this->gerrit_version, $this->http_password);
     stub($this->dao)->save()->returns(113);
     $this->factory->save($new_server);
     $this->assertEqual($new_server->getId(), 113);
 }
 private function updateServers(array $request_gerrit_servers)
 {
     foreach ($request_gerrit_servers as $id => $settings) {
         $server = $this->servers[$id];
         if (empty($server)) {
             continue;
         }
         if (!empty($settings['delete'])) {
             $this->gerrit_server_factory->delete($server);
             unset($this->servers[$id]);
             continue;
         }
         $host = isset($settings['host']) ? $settings['host'] : '';
         $ssh_port = isset($settings['ssh_port']) ? $settings['ssh_port'] : '';
         $http_port = isset($settings['http_port']) ? $settings['http_port'] : '';
         $login = isset($settings['login']) ? $settings['login'] : '';
         $identity_file = isset($settings['identity_file']) ? $settings['identity_file'] : '';
         $replication_ssh_key = isset($settings['replication_key']) ? $settings['replication_key'] : '';
         $use_ssl = isset($settings['use_ssl']);
         $gerrit_version = isset($settings['gerrit_version']) ? $settings['gerrit_version'] : '';
         $http_password = isset($settings['http_password']) ? $settings['http_password'] : '';
         if ($host !== '' && ($host != $server->getHost() || $ssh_port != $server->getSSHPort() || $http_port != $server->getHTTPPort() || $login != $server->getLogin() || $identity_file != $server->getIdentityFile() || $replication_ssh_key != $server->getReplicationKey() || $use_ssl != $server->usesSSL() || $gerrit_version != $server->getGerritVersion() || $http_password != $server->getHTTPPassword())) {
             $server->setHost($host)->setSSHPort($ssh_port)->setHTTPPort($http_port)->setLogin($login)->setIdentityFile($identity_file)->setReplicationKey($replication_ssh_key)->setUseSSL($use_ssl)->setGerritVersion($gerrit_version)->setHTTPPassword($http_password);
             $this->gerrit_server_factory->save($server);
             $this->servers[$server->getId()] = $server;
         }
     }
 }