/** * 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)); }
/** * Clears all trigger logs * @deprecated Use X2FlowTestingAuxLib::clearLogs instead */ public function clearLogs() { return X2FlowTestingAuxLib::clearLogs(); }
public static function tearDownAfterClass() { X2FlowTestingAuxLib::clearLogs(); parent::tearDownAfterClass(); }