Пример #1
0
 /**
  * Overrides Mollom::handleRequest().
  *
  * Mollom::$server is replaced with an invalid server, so all requests will
  * result in a network error. However, if the 'mollom_testing_server_failover'
  * variable is set to TRUE, then the last request attempt will succeed.
  */
 protected function handleRequest($method, $server, $path, $data, $expected = [])
 {
     $this->currentAttempt++;
     if (\Drupal::state()->get('mollom_testing_server_failover', FALSE) && $this->currentAttempt == $this->requestMaxAttempts) {
         $server = strtr($server, [$this->server => $this->originalServer]);
     }
     return parent::handleRequest($method, $server, $path, $data, $expected);
 }
Пример #2
0
 /**
  * Overrides MollomDrupal::request().
  *
  * Passes-through SimpleTest assertion HTTP headers from child-child-site and
  * triggers errors to make them appear in parent site (where tests are ran).
  *
  * @todo Remove when in core.
  * @see http://drupal.org/node/875342
  */
 protected function request($method, $server, $path, $query = NULL, array $headers = array())
 {
     $response = parent::request($method, $server, $path, $query, $headers);
     $keys = preg_grep('@^x-drupal-assertion-@', array_keys($response->headers));
     foreach ($keys as $key) {
         $header = $response->headers[$key];
         $header = unserialize(urldecode($header));
         $message = strtr('%type: @message in %function (line %line of %file).', array('%type' => $header[1], '@message' => $header[0], '%function' => $header[2]['function'], '%line' => $header[2]['line'], '%file' => $header[2]['file']));
         trigger_error($message, E_USER_ERROR);
     }
     // Convert the body from Guzzle stream to string data.
     if (!empty($response->body) && is_callable(array($response->body, 'getContents'))) {
         $response->body = $response->body->getContents();
     }
     return $response;
 }