Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#980 [test-dbunit] remove dependencies on discontinued dbunit test package #14319

Merged
merged 1 commit into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions tests/phpunit/CRM/Activity/BAO/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1284,12 +1284,7 @@ public function createSendSmsTest($phoneType = 0, $passPhoneTypeInContactDetails
}

protected function createTestActivities() {
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/activities_for_dashboard_count.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/activities_for_dashboard_count.xml');
// Make changes to improve variation in php since the xml method is brittle & relies on option values being unchanged.
$this->callAPISuccess('Activity', 'create', ['id' => 12, 'activity_type_id' => 'Bulk Email']);
}
Expand Down
29 changes: 5 additions & 24 deletions tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ public function tearDown() {
public function testCount($fv, $count, $ids, $full) {
$this->quickCleanup($this->_tablesToTruncate);

// echo "testCount\n";
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/datasets/group-dataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/datasets/group-dataset.xml');

$obj = new CRM_Contact_Form_Search_Custom_Group($fv);

Expand All @@ -111,9 +105,7 @@ public function testCount($fv, $count, $ids, $full) {
* echo "{$dao->contact_id}, {$dao->contact_type}, {$dao->sort_name}, {$dao->group_names}\n";
* }
**/
$this->assertEquals($count, $obj->count(),
'In line ' . __LINE__
);
$this->assertEquals($count, $obj->count());
}

/**
Expand All @@ -128,14 +120,8 @@ public function testCount($fv, $count, $ids, $full) {
public function testAll($fv, $count, $ids, $full) {
// Truncate affected tables
$this->quickCleanup($this->_tablesToTruncate);
$this->loadXMLDataSet(dirname(__FILE__) . '/datasets/group-dataset.xml');

// echo "testAll\n";
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/datasets/group-dataset.xml'
)
);
$obj = new CRM_Contact_Form_Search_Custom_Group($fv);
$sql = $obj->all();
$this->assertTrue(is_string($sql));
Expand Down Expand Up @@ -165,13 +151,8 @@ public function testContactIDs($fv, $count, $ids, $full) {
// Truncate affected tables
$this->quickCleanup($this->_tablesToTruncate);

// echo "testContactIDs\n";
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/datasets/group-dataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/datasets/group-dataset.xml');

$obj = new CRM_Contact_Form_Search_Custom_Group($fv);
$sql = $obj->contactIDs();
$this->assertTrue(is_string($sql));
Expand Down
36 changes: 6 additions & 30 deletions tests/phpunit/CRM/Contact/Form/Search/Custom/SampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@ public function tearDown() {
public function testCount($fv, $count, $ids, $full) {
$this->quickCleanup($this->_tablesToTruncate);

// echo "testCount\n";
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/datasets/sample-dataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/datasets/sample-dataset.xml');

$obj = new CRM_Contact_Form_Search_Custom_Sample($fv);

$this->assertEquals($count, $obj->count(),
'In line ' . __LINE__
);
$this->assertEquals($count, $obj->count());
}

/**
Expand All @@ -114,13 +106,8 @@ public function testAll($fv, $count, $ids, $full) {
// Truncate affected tables
$this->quickCleanup($this->_tablesToTruncate);

// echo "testAll\n";
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/datasets/sample-dataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/datasets/sample-dataset.xml');

$obj = new CRM_Contact_Form_Search_Custom_Sample($fv);
$sql = $obj->all(0, 0, 'contact_id');
$this->assertTrue(is_string($sql));
Expand Down Expand Up @@ -150,13 +137,7 @@ public function testContactIDs($fv, $count, $ids, $full) {
// Truncate affected tables
$this->quickCleanup($this->_tablesToTruncate);

// echo "testContactIDs\n";
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/datasets/sample-dataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/datasets/sample-dataset.xml');
$obj = new CRM_Contact_Form_Search_Custom_Sample($fv);
$sql = $obj->contactIDs();
$this->assertTrue(is_string($sql));
Expand Down Expand Up @@ -222,12 +203,7 @@ public function testTemplateFile() {
public function testSavedSearch() {
$this->quickCleanup($this->_tablesToTruncate);

$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/datasets/sample-dataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/datasets/sample-dataset.xml');

$dataset[1] = array('id' => array(12));
$dataset[2] = array('id' => array(10, 11));
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/CRM/Core/BAO/IMTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ public function testAdd() {
* AllIMs() method - get all IMs for our contact, with primary IM first
*/
public function testAllIMs() {
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute(
$this->_dbconn,
$this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/im_test.xml')
);
$this->loadXMLDataSet(dirname(__FILE__) . '/dataset/im_test.xml');

$contactId = 69;
$IMs = CRM_Core_BAO_IM::allIMs($contactId);
Expand Down
21 changes: 3 additions & 18 deletions tests/phpunit/CRM/Mailing/BAO/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ public function tearDown() {
* @param $full
*/
public function testSearch($fv, $count, $ids, $full) {
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/queryDataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/queryDataset.xml');

$params = CRM_Contact_BAO_Query::convertFormValues($fv);
$obj = new CRM_Contact_BAO_Query($params);
Expand All @@ -73,13 +68,8 @@ public function testSearch($fv, $count, $ids, $full) {
* CRM-20412: Test accurate count for unique open details
*/
public function testOpenedMailingQuery() {
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/queryDataset.xml'
)
);

$this->loadXMLDataSet(dirname(__FILE__) . '/queryDataset.xml');
// ensure that total unique opened mail count is same while
// fetching rows and row count for mailing_id = 14
$totalOpenedMailCount = CRM_Mailing_Event_BAO_Opened::getTotalCount(14, NULL, TRUE);
Expand All @@ -93,12 +83,7 @@ public function testOpenedMailingQuery() {
* CRM-21194: Test accurate count for unique trackable URLs
*/
public function testTrackableUrlMailingQuery() {
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/queryDataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/queryDataset.xml');

// ensure that total unique clicked mail count is same while
// fetching rows and row count for mailing_id = 14 and
Expand Down
10 changes: 3 additions & 7 deletions tests/phpunit/CRM/Member/Form/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,9 @@ public function setUp() {

$this->_individualId = $this->individualCreate();
$this->_paymentProcessorID = $this->processorCreate();
// Insert test data.
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/dataset/data.xml'
)
);

$this->loadXMLDataSet(dirname(__FILE__) . '/dataset/data.xml');

$membershipTypeAnnualFixed = $this->callAPISuccess('membership_type', 'create', array(
'domain_id' => 1,
'name' => "AnnualFixed",
Expand Down
8 changes: 5 additions & 3 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,19 @@ protected function loadXMLDataSet($fileName) {
$values[] = is_numeric($value) ? $value : "'{$value}'";
}
}
else {
elseif (!empty($row)) {
// cos we copied it & it is inconsistent....
foreach ($row as $key => $value) {
$keys[] = $key;
$values[] = is_numeric($value) ? $value : "'{$value}'";
}
}

CRM_Core_DAO::executeQuery("
if (!empty($values)) {
CRM_Core_DAO::executeQuery("
INSERT INTO $tableName (" . implode(',', $keys) . ') VALUES(' . implode(',', $values) . ')'
);
);
}
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions tests/phpunit/api/v3/ReportTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,7 @@ public function testReportTemplateGetRowsContactSummary() {
*/
public function testReportTemplateGetRowsMailingUniqueOpened() {
$description = "Retrieve rows from a mailing opened report template.";
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/../../CRM/Mailing/BAO/queryDataset.xml'
)
);
$this->loadXMLDataSet(dirname(__FILE__) . '/../../CRM/Mailing/BAO/queryDataset.xml');

// Check total rows without distinct
global $_REQUEST;
Expand Down
8 changes: 1 addition & 7 deletions tests/phpunit/api/v3/UFFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {

protected $_contactId = 69;

protected $_apiversion = 3;

protected $_params;

protected $_entity = 'uf_field';
Expand All @@ -70,11 +68,7 @@ protected function setUp() {
]
);

$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute(
$this->_dbconn,
$this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml')
);
$this->loadXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml');

$this->callAPISuccess('uf_field', 'getfields', ['cache_clear' => 1]);

Expand Down
8 changes: 1 addition & 7 deletions tests/phpunit/api/v3/UFJoinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class api_v3_UFJoinTest extends CiviUnitTestCase {
protected $_ufGroupId = 11;
protected $_ufFieldId;
protected $_contactId = 69;
protected $_apiversion;

protected function setUp() {
parent::setUp();
Expand All @@ -54,12 +53,7 @@ protected function setUp() {
'civicrm_uf_match',
)
);
$this->_apiversion = 3;
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute(
$this->_dbconn,
$this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml')
);
$this->loadXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml');
}

public function tearDown() {
Expand Down
8 changes: 1 addition & 7 deletions tests/phpunit/api/v3/UFMatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ class api_v3_UFMatchTest extends CiviUnitTestCase {
protected $_ufGroupId = 11;
protected $_ufFieldId;
protected $_contactId;
protected $_apiversion;
protected $_params = array();

protected function setUp() {
parent::setUp();
$this->_apiversion = 3;
$this->quickCleanup(
array(
'civicrm_group',
Expand All @@ -56,11 +54,7 @@ protected function setUp() {
)
);
$this->_contactId = $this->individualCreate();
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute(
$this->_dbconn,
$this->createFlatXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml')
);
$this->loadXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml');

$this->_params = array(
'contact_id' => $this->_contactId,
Expand Down