private function serverToData(Server $server)
 {
     $data = new stdClass();
     $data->installer = $server->getInstallerName();
     $data->{'document-root'} = $server->getDocumentRoot();
     if (Server::DEFAULT_URL_FORMAT !== ($urlFormat = $server->getUrlFormat())) {
         $data->{'url-format'} = $urlFormat;
     }
     if ($parameters = $server->getParameterValues()) {
         $data->parameters = (object) $parameters;
     }
     return $data;
 }
Exemple #2
0
 private function serversEqual(Server $server1, Server $server2)
 {
     if ($server1->getName() !== $server2->getName()) {
         return false;
     }
     if ($server1->getInstallerName() !== $server2->getInstallerName()) {
         return false;
     }
     if ($server1->getDocumentRoot() !== $server2->getDocumentRoot()) {
         return false;
     }
     if ($server1->getUrlFormat() !== $server2->getUrlFormat()) {
         return false;
     }
     $parameters1 = $server1->getParameterValues();
     $parameters2 = $server2->getParameterValues();
     ksort($parameters1);
     ksort($parameters2);
     if ($parameters1 !== $parameters2) {
         return false;
     }
     return true;
 }
Exemple #3
0
 public function testMatch()
 {
     $server = new Server('localhost', 'symlink', 'web', '/%s', array('param1' => 'value1', 'param2' => 'value2'));
     $this->assertFalse($server->match(Expr::same('foobar', Server::NAME)));
     $this->assertTrue($server->match(Expr::same('localhost', Server::NAME)));
     $this->assertFalse($server->match(Expr::same('foobar', Server::INSTALLER_NAME)));
     $this->assertTrue($server->match(Expr::same('symlink', Server::INSTALLER_NAME)));
     $this->assertFalse($server->match(Expr::same('foobar', Server::DOCUMENT_ROOT)));
     $this->assertTrue($server->match(Expr::same('web', Server::DOCUMENT_ROOT)));
     $this->assertFalse($server->match(Expr::same('foobar', Server::URL_FORMAT)));
     $this->assertTrue($server->match(Expr::same('/%s', Server::URL_FORMAT)));
     $this->assertFalse($server->match(Expr::key(Server::PARAMETER_VALUES, Expr::keyExists('foobar'))));
     $this->assertTrue($server->match(Expr::key(Server::PARAMETER_VALUES, Expr::keyExists('param1'))));
 }
 /**
  * Adds a server to the collection.
  *
  * @param Server $server The server to add.
  */
 public function add(Server $server)
 {
     $this->servers[$server->getName()] = $server;
 }
 /**
  * Returns the document root of the server.
  *
  * This can be a directory name, a URL or any other string that can be
  * interpreted by the installer.
  *
  * @return string The document root.
  */
 public function getDocumentRoot()
 {
     return $this->server->getDocumentRoot();
 }