quickCleanUpFinancialEntities(); parent::tearDown(); } /** * Test links render correctly for manual processor. * * @throws \API_Exception * @throws \CiviCRM_API3_Exception */ public function testLinksManual(): void { [$contactID, $recurID] = $this->setupTemplate(); $templateVariable = CRM_Core_Smarty::singleton()->get_template_vars(); $this->assertEquals('Mr. Anthony Anderson II', $templateVariable['displayName']); $this->assertEquals("ViewEditCancel", $this->getActionHtml() ); } /** * Test links render correctly for manual processor. * * @throws \API_Exception * @throws \CiviCRM_API3_Exception */ public function testLinksPaypalStandard(): void { $this->setupTemplate([ 'payment_processor_id' => $this->paymentProcessorCreate(['payment_processor_type_id' => 'PayPal_Standard']), 'contact_id' => $this->createLoggedInUser(), ]); $expected = 'ViewEditmore'; $this->assertEquals($expected, $this->getActionHtml()); $page = new CRM_Contribute_Page_UserDashboard(); $page->run(); $expected = 'Cancel' . 'View' . 'more'; $this->assertEquals( $expected, $this->getDashboardActionHtml() ); } /** * Set up template for user dashboard. * * Create the recurring contribution, contribution and run the dashboard. * * @param array $recurParams * * @return array * @throws \API_Exception * @throws \CiviCRM_API3_Exception * @throws \Civi\API\Exception\UnauthorizedException */ protected function setupTemplate($recurParams = []): array { $contactID = $recurParams['contact_id'] ?? $this->individualCreate(); $recurID = ContributionRecur::create()->setValues(array_merge([ 'contact_id' => $contactID, 'amount' => 10, 'frequency_interval' => 'week', 'start_date' => 'now', 'is_active' => TRUE, 'contribution_status_id:name' => 'Pending', ], $recurParams)) ->addChain( 'contribution', Contribution::create()->setValues([ 'contribution_id' => '$id', 'financial_type_id:name' => 'Donation', 'total_amount' => 60, 'receive_date' => 'now', 'contact_id' => $contactID, ]) )->execute()->first()['id']; $page = new CRM_Contribute_Page_Tab(); $page->_contactId = $contactID; $page->_action = CRM_Core_Action::VIEW; $page->browse(); return [$contactID, $recurID]; } /** * Get the html assigned as actions. * * @return string */ protected function getActionHtml(): string { return CRM_Core_Smarty::singleton() ->get_template_vars()['activeRecurRows'][1]['action']; } /** * Get the html assigned as actions. * * @return string */ protected function getDashboardActionHtml(): string { return CRM_Core_Smarty::singleton() ->get_template_vars()['recurRows'][1]['action']; } }