From: Seamus Lee Date: Thu, 21 Nov 2019 06:04:31 +0000 (+1100) Subject: Add in unit test of the priceset custom search X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=630e190b22b67fb1a974ef84ff5a65b8474da7ed;p=civicrm-core.git Add in unit test of the priceset custom search --- diff --git a/tests/phpunit/CRM/Contact/Form/Search/Custom/PriceSetTest.php b/tests/phpunit/CRM/Contact/Form/Search/Custom/PriceSetTest.php new file mode 100644 index 0000000000..4744b9d713 --- /dev/null +++ b/tests/phpunit/CRM/Contact/Form/Search/Custom/PriceSetTest.php @@ -0,0 +1,83 @@ + (801) 534-1262 + * @copyright Copyright CiviCRM LLC (C) 2009 + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html + * GNU Affero General Public License version 3 + * @package CiviCRM + * + * This file is part of CiviCRM + * + * CiviCRM is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * CiviCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this program. If not, see + * . + */ + +/** + * Include parent class definition + */ + + +/** + * Include class under test + */ + +/** + * Include form definitions + */ + +/** + * Include DAO to do queries + */ + +/** + * Include dataProvider for tests + */ + +/** + * Test contact custom search functions + * + * @package CiviCRM + * @group headless + */ +class CRM_Contact_Form_Search_Custom_PriceSetTest extends CiviUnitTestCase { + + public function setUp() { + parent::setUp(); + } + + public function tearDown() { + } + + public function testRunSearch() { + $order = $this->callAPISuccess('Order', 'create', $this->getParticipantOrderParams()); + $this->callAPISuccess('Payment', 'create', [ + 'order_id' => $order['id'], + 'total_amount' => 50, + ]); + $this->validateAllPayments(); + $formValues = ['event_id' => $this->_eventId]; + $form = new CRM_Contact_Form_Search_Custom_PriceSet($formValues); + $sql = $form->all(); + // Assert that we have created a standard temp table + $this->assertContains('civicrm_tmp_e_priceset', $sql); + // Check that the temp table has been populated. + $result = CRM_Core_DAO::executeQuery($sql)->fetchAll(); + $this->assertTrue(!empty($result)); + } + +}