Example #1
0
 /**
  * Ensure that update and create trigger appropriate flows
  */
 public function testContacts()
 {
     X2FlowTestingAuxLib::clearLogs($this);
     $this->action = 'model';
     $this->assertEquals(array(), TriggerLog::model()->findAll());
     // Create
     $contact = array('firstName' => 'Walt', 'lastName' => 'White', 'email' => '*****@*****.**', 'visibility' => 1, 'trackingKey' => '1234');
     $ch = $this->getCurlHandle('POST', array('{modelAction}' => 'Contacts'), 'admin', $contact);
     $response = json_decode(curl_exec($ch), 1);
     $id = $response['id'];
     $this->assertResponseCodeIs(201, $ch);
     $this->assertTrue((bool) ($newContact = Contacts::model()->findBySql('SELECT * FROM x2_contacts
             WHERE firstName="Walt" 
             AND lastName="White" 
             AND email="*****@*****.**"
             AND trackingKey="1234"')));
     $logs = TriggerLog::model()->findAll();
     $this->assertEquals(1, count($logs));
     $trace = X2FlowTestingAuxLib::getTraceByFlowId($this->flows('flow1')->id);
     $this->assertTrue(is_array($trace));
     $this->assertTrue(X2FlowTestingAuxLib::checkTrace($trace));
     // Update
     $contact['firstName'] = 'Walter';
     $ch = $this->getCurlHandle('PUT', array('{modelAction}' => "Contacts/{$id}.json"), 'admin', $contact);
     $response = json_decode(curl_exec($ch), 1);
     $this->assertResponseCodeIs(200, $ch);
     $newContact->refresh();
     $this->assertEquals($contact['firstName'], $newContact['firstName']);
     $logs = TriggerLog::model()->findAll();
     $this->assertEquals(2, count($logs));
     $trace = X2FlowTestingAuxLib::getTraceByFlowId($this->flows('flow2')->id);
     $this->assertTrue(is_array($trace));
     $this->assertTrue(X2FlowTestingAuxLib::checkTrace($trace));
 }
Example #2
0
 /**
  * Checks each entry in triggerLog looking for errors
  * @param array $trace One of the return value of executeFlow ()
  * @return bool false if an error was found in the log, true otherwise
  * @deprecated Use X2FlowTestingAuxLib::checkTrace instead
  */
 public function checkTrace($trace)
 {
     return X2FlowTestingAuxLib::checkTrace($trace);
 }
Example #3
0
 public static function tearDownAfterClass()
 {
     X2FlowTestingAuxLib::clearLogs();
     parent::tearDownAfterClass();
 }