4 * Include dataProvider for tests
6 class CRM_Mailing_BAO_QueryTest
extends CiviUnitTestCase
{
9 * @return CRM_Mailing_BAO_QueryTestDataProvider
11 public function dataProvider() {
12 return new CRM_Mailing_BAO_QueryTestDataProvider();
15 public function setUp() {
19 public function tearDown() {
20 $tablesToTruncate = array(
21 'civicrm_mailing_event_bounce',
22 'civicrm_mailing_event_delivered',
23 'civicrm_mailing_event_opened',
24 'civicrm_mailing_event_reply',
25 'civicrm_mailing_event_trackable_url_open',
26 'civicrm_mailing_event_queue',
27 'civicrm_mailing_trackable_url',
28 'civicrm_mailing_job',
30 'civicrm_mailing_recipients',
34 $this->quickCleanup($tablesToTruncate);
38 * Test CRM_Contact_BAO_Query::searchQuery()
39 * @dataProvider dataProvider
45 public function testSearch($fv, $count, $ids, $full) {
46 $op = new PHPUnit_Extensions_Database_Operation_Insert();
47 $op->execute($this->_dbconn
,
48 $this->createFlatXMLDataSet(
49 dirname(__FILE__
) . '/queryDataset.xml'
53 $params = CRM_Contact_BAO_Query
::convertFormValues($fv);
54 $obj = new CRM_Contact_BAO_Query($params);
56 // let's set useGroupBy=true, to prevent duplicate records
57 $obj->_useGroupBy
= TRUE;
59 $dao = $obj->searchQuery();
62 while ($dao->fetch()) {
63 $contacts[] = $dao->contact_id
;
66 sort($contacts, SORT_NUMERIC
);
68 $this->assertEquals($ids, $contacts);