tests/phpunit/** - Remove unnecessary "require_once" statements
[civicrm-core.git] / tests / phpunit / CRM / Mailing / BAO / QueryTest.php
1 <?php
2
3 /**
4 * Include dataProvider for tests
5 */
6 class CRM_Mailing_BAO_QueryTest extends CiviUnitTestCase {
7
8 /**
9 * @return CRM_Mailing_BAO_QueryTestDataProvider
10 */
11 public function dataProvider() {
12 return new CRM_Mailing_BAO_QueryTestDataProvider();
13 }
14
15 public function setUp() {
16 parent::setUp();
17 }
18
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',
29 'civicrm_mailing',
30 'civicrm_mailing_recipients',
31 'civicrm_email',
32 'civicrm_contact',
33 );
34 $this->quickCleanup($tablesToTruncate);
35 }
36
37 /**
38 * Test CRM_Contact_BAO_Query::searchQuery()
39 * @dataProvider dataProvider
40 * @param $fv
41 * @param $count
42 * @param $ids
43 * @param $full
44 */
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'
50 )
51 );
52
53 $params = CRM_Contact_BAO_Query::convertFormValues($fv);
54 $obj = new CRM_Contact_BAO_Query($params);
55
56 // let's set useGroupBy=true, to prevent duplicate records
57 $obj->_useGroupBy = TRUE;
58
59 $dao = $obj->searchQuery();
60
61 $contacts = array();
62 while ($dao->fetch()) {
63 $contacts[] = $dao->contact_id;
64 }
65
66 sort($contacts, SORT_NUMERIC);
67
68 $this->assertEquals($ids, $contacts);
69 }
70
71 }