Commit 23355f09 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

add test case

parent c0581606
......@@ -100,7 +100,7 @@ class api_v3_Job_MosaicoMsgSyncTest extends \PHPUnit\Framework\TestCase implemen
$oldCount = CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_msg_template');
// Create the clone and run the sync on it passing is_new (which is what the post hook does).
$second = civicrm_api3('MosaicoTemplate', 'clone', ['id'=>$first['id'], 'title' => 'clone']);
$second = civicrm_api3('MosaicoTemplate', 'clone', ['id' => $first['id'], 'title' => 'clone']);
$result = civicrm_api3('Job', 'mosaico_msg_sync', ['id' => $second['id'], 'is_new' => TRUE]);
// Count templates - should be one more.
......@@ -108,6 +108,25 @@ class api_v3_Job_MosaicoMsgSyncTest extends \PHPUnit\Framework\TestCase implemen
$this->assertEquals(1 + $oldCount, $newCount);
}
/**
* Test deletion of message template corresponding to masaico template
*/
public function testDelete() {
$this->assertEquals('MosaicoTemplate', CRM_Core_DAO_AllCoreTables::getBriefName('CRM_Mosaico_DAO_MosaicoTemplate'));
// Create the first template and run the sync.
$first = $this->createMosaicoTemplate(array('title' => 'First example'));
civicrm_api3('Job', 'mosaico_msg_sync', ['id' => $first['id']]);
// Delete mosaico template
civicrm_api3('MosaicoTemplate', 'delete', array('id' => $first['id']));
// make sure message template is deleted
$result = civicrm_api3('MessageTemplate', 'getsingle', ['id' => $first['msg_tpl_id']]);
$this->assertEquals($result['count'], 0);
}
/**
* Test title/subject parsing.
*
......@@ -150,5 +169,4 @@ class api_v3_Job_MosaicoMsgSyncTest extends \PHPUnit\Framework\TestCase implemen
$msgTpl = civicrm_api3('MosaicoTemplate', 'create', array_merge($defaults, $params));
return $msgTpl['values'][$msgTpl['id']];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment