Skip to content

Commit

Permalink
Merge pull request #18189 from demeritcowboy/widget-notice
Browse files Browse the repository at this point in the history
E_NOTICE on contribution page widget tab
  • Loading branch information
eileenmcnaughton authored Aug 18, 2020
2 parents 0beda1f + 3699ac5 commit 476123c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ContributionPage/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function preProcess() {

$this->assign('cpageId', $this->_id);

$this->assign('widgetExternUrl', CRM_Utils_System::externUrl('extern/widget', "cpageId={$this->_id}&widgetId={$this->_widget->id}&format=3"));
$this->assign('widgetExternUrl', CRM_Utils_System::externUrl('extern/widget', "cpageId={$this->_id}&widgetId=" . ($this->_widget->id ?? '') . "&format=3"));

$config = CRM_Core_Config::singleton();
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage',
Expand Down
28 changes: 28 additions & 0 deletions tests/phpunit/CRM/Contribute/Form/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1721,4 +1721,32 @@ public function testPreProcessContributionEdit() {
unset($_REQUEST['id']);
}

/**
* Mostly just check there's no errors opening the Widget tab on contribution
* pages.
*/
public function testOpeningWidgetAdminPage() {
$page_id = $this->callAPISuccess('ContributionPage', 'create', [
'title' => 'my page',
'financial_type_id' => $this->_financialTypeId,
'payment_processor' => $this->paymentProcessorID,
])['id'];

$form = new CRM_Contribute_Form_ContributionPage_Widget();
$form->controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_ContributionPage_Widget', 'Widget');

$form->set('reset', '1');
$form->set('action', 'update');
$form->set('id', $page_id);

ob_start();
$form->controller->_actions['display']->perform($form, 'display');
$contents = ob_get_contents();
ob_end_clean();

// The page contents load later by ajax, so there's just the surrounding
// html available now, but we can check at least one thing while we're here.
$this->assertStringContainsString("selectedTab = 'widget';", $contents);
}

}

0 comments on commit 476123c

Please sign in to comment.