public function testExecuteCurlFailure()
 {
     $error_handler = new ErrorHandler();
     $consumer = new ConsumerStrategies_CurlConsumer(array("host" => "some.domain.that.should.not.ever.exist.tld", "endpoint" => "/endpoint", "timeout" => 2, "use_ssl" => false, "fork" => false, "error_callback" => array($error_handler, 'handle_error')));
     $resp = $consumer->persist(array("msg"));
     $this->assertFalse($resp);
     $this->assertEquals($error_handler->last_code, CURLE_COULDNT_RESOLVE_HOST);
 }
Exemplo n.º 2
0
 /**
  * Alias an existing id with a different unique id. This is helpful when you want to associate a generated id to
  * a username or e-mail address.
  *
  * Because aliasing can be extremely vulnerable to race conditions and ordering issues, we'll make a synchronous
  * call directly to Mixpanel when this method is called. If it fails we'll throw an Exception as subsequent
  * events are likely to be incorrectly tracked.
  * @param string|int $original_id
  * @param string|int $new_id
  * @return array $msg
  * @throws Exception
  */
 public function createAlias($original_id, $new_id)
 {
     $msg = array("event" => '$create_alias', "properties" => array("distinct_id" => $original_id, "alias" => $new_id, "token" => $this->_token));
     $options = array_merge($this->_options, array("endpoint" => $this->_getEndpoint(), "fork" => false));
     $curlConsumer = new ConsumerStrategies_CurlConsumer($options);
     $success = $curlConsumer->persist(array($msg));
     if (!$success) {
         error_log("Creating Mixpanel Alias (original id: {$original_id}, new id: {$new_id}) failed");
         throw new Exception("Tried to create an alias but the call was not successful");
     } else {
         return $msg;
     }
 }