diff --git a/CRM/Pledge/Selector/Search.php b/CRM/Pledge/Selector/Search.php index f4dfc6dd8e38..c862e4e59e64 100644 --- a/CRM/Pledge/Selector/Search.php +++ b/CRM/Pledge/Selector/Search.php @@ -319,9 +319,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['campaign_id'] = $result->pledge_campaign_id; // add pledge status name - $row['pledge_status_name'] = CRM_Utils_Array::value($row['pledge_status_id'], - $pledgeStatuses - ); + if (!empty($row['pledge_status_id'])) { + $row['pledge_status_name'] = CRM_Utils_Array::value($row['pledge_status_id'], + $pledgeStatuses + ); + } // append (test) to status label if (!empty($row['pledge_is_test'])) { $row['pledge_status'] .= ' (test)'; diff --git a/tests/phpunit/CRM/Pledge/Form/SearchTest.php b/tests/phpunit/CRM/Pledge/Form/SearchTest.php new file mode 100644 index 000000000000..351701b2c0eb --- /dev/null +++ b/tests/phpunit/CRM/Pledge/Form/SearchTest.php @@ -0,0 +1,57 @@ +individualID = $this->individualCreate(); + $this->pledgeCreate(array('contact_id' => $this->individualID)); + } + public function tearDown() { + parent::tearDown(); + $tablesToTruncate = array( + 'civicrm_activity', + 'civicrm_activity_contact', + 'civicrm_pledge', + ); + $this->quickCleanup($tablesToTruncate); + } + /** + * Test submitted the search form. + */ + public function testSearch() { + $form = new CRM_Pledge_Form_Search(); + $_SERVER['REQUEST_METHOD'] = 'GET'; + $form->controller = new CRM_Pledge_Controller_Search(); + $form->preProcess(); + $form->postProcess(); + $qfKey = $form->controller->_key; + $date = date('Y-m-d h:m:s'); + $rows = $form->controller->get('rows'); + $this->assertEquals(array( + 'contact_id' => '3', + 'sort_name' => 'Anderson, Anthony', + 'display_name' => 'Mr. Anthony Anderson II', + 'pledge_id' => '1', + 'pledge_amount' => '100.00', + 'pledge_create_date' => $date, + 'pledge_next_pay_date' => $date, + 'pledge_next_pay_amount' => '20.00', + 'pledge_status_id' => '2', + 'pledge_status' => 'Pending', + 'pledge_is_test' => '0', + 'pledge_financial_type' => 'Donation', + 'pledge_currency' => 'USD', + 'campaign' => NULL, + 'campaign_id' => NULL, + 'pledge_status_name' => 'Pending', + 'checkbox' => 'mark_x_1', + 'action' => 'ViewEditmore', + 'contact_type' => '
', + ), $rows[0]); + } + +}