From 4917abe95910b06c6fc763e9ce6bb0d54ae61ab2 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 19 May 2018 13:29:50 +1000 Subject: [PATCH] dev/core#118 Fix Count issues with PledgePayment and Pledge BAO tests --- tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php | 11 ++++++----- tests/phpunit/CRM/Pledge/BAO/PledgeTest.php | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php index b4d4ed8904..127c64bebc 100644 --- a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php +++ b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php @@ -97,7 +97,7 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { $defaults = array(); $paymentid = CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); - $this->assertEquals(count($paymentid), 0, "Pledge Id must be greater than 0"); + $this->assertEquals(is_null($paymentid), 1, "Pledge Id must be greater than 0"); $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id); } @@ -110,7 +110,7 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { $defaults = array(); $paymentid = CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); - $this->assertEquals(count($paymentid), 0, "Pledge Id cannot be a string"); + $this->assertEquals(is_null($paymentid), 1, "Pledge Id cannot be a string"); $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id); } @@ -124,7 +124,7 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { $defaults = array(); $paymentid = CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); - $this->assertEquals(count($paymentid), 1, "Pledge was retrieved"); + $this->assertEquals($paymentid->N, 1, "Pledge was retrieved"); $result = CRM_Pledge_BAO_Pledge::deletePledge($pledgeId); } @@ -134,7 +134,8 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { public function testDeletePledgePaymentsNormal() { $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); $paymentid = CRM_Pledge_BAO_PledgePayment::deletePayments($payment->pledge_id); - $this->assertEquals(count($paymentid), 1, "Deleted one payment"); + + $this->assertEquals($paymentid, 1, "Deleted one payment"); $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id); } @@ -157,7 +158,7 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { public function testDeletePledgePaymentsNullId() { $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); $paymentid = CRM_Pledge_BAO_PledgePayment::deletePayments(NULL); - $this->assertEquals(count($paymentid), 1, "No payments deleted"); + $this->assertFalse($paymentid, "No payments deleted"); $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id); } diff --git a/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php b/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php index e20daaaebb..e3c0fa3f32 100644 --- a/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php +++ b/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php @@ -103,7 +103,7 @@ class CRM_Pledge_BAO_PledgeTest extends CiviUnitTestCase { $params = array('pledge_id' => 0); $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($params, $defaults); - $this->assertEquals(count($pledgeId), 0, "Pledge Id must be greater than 0"); + $this->assertEquals(is_null($pledgeId), 1, "Pledge Id must be greater than 0"); } /** @@ -114,7 +114,7 @@ class CRM_Pledge_BAO_PledgeTest extends CiviUnitTestCase { $params = array('pledge_id' => 'random text'); $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($params, $defaults); - $this->assertEquals(count($pledgeId), 0, "Pledge Id must be a string"); + $this->assertEquals(is_null($pledgeId), 1, "Pledge Id must be a string"); } /** @@ -144,7 +144,7 @@ class CRM_Pledge_BAO_PledgeTest extends CiviUnitTestCase { $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($pledgeParams, $defaults); - $this->assertEquals(count($pledgeId), 1, "Pledge was retrieved"); + $this->assertEquals($pledgeId->N, 1, "Pledge was retrieved"); } /** -- 2.25.1