-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12085 from seamuslee001/pledge_search_form_test
(NFC) Add unit test of submitting the Pledge Search Form
- Loading branch information
Showing
2 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/** | ||
* Include dataProvider for tests | ||
* @group headless | ||
*/ | ||
class CRM_Pledge_Form_SearchTest extends CiviUnitTestCase { | ||
public function setUp() { | ||
parent::setUp(); | ||
$this->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') . ' 00:00:00'; | ||
$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' => '<span><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&id=1&cid=3&action=view&context=search&selectedChild=pledge&key=' . $qfKey . '" class="action-item crm-hover-button" title=' . "'" . 'View Pledge' . "'" . ' >View</a><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&action=update&id=1&cid=3&context=search&key=' . $qfKey . '" class="action-item crm-hover-button" title=' . "'" . 'Edit Pledge' . "'" . ' >Edit</a></span><span class=' . "'" . 'btn-slide crm-hover-button' . "'" . '>more<ul class=' . "'" . 'panel' . "'" . '><li><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&action=detach&id=1&cid=3&context=search&key=' . $qfKey . '" class="action-item crm-hover-button" title=' . "'" . 'Cancel Pledge' . "'" . ' onclick = "return confirm(' . "'" . 'Cancelling this pledge will also cancel any scheduled (and not completed) pledge payments. This action cannot be undone. Do you want to continue?' . "'" . ');">Cancel</a></li><li><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&action=delete&id=1&cid=3&context=search&key=' . $qfKey . '" class="action-item crm-hover-button small-popup" title=' . "'" . 'Delete Pledge' . "'" . ' >Delete</a></li></ul></span>', | ||
'contact_type' => '<a href="/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>', | ||
), $rows[0]); | ||
} | ||
|
||
} |