Merge pull request #14925 from civicrm/5.16
[civicrm-core.git] / tests / phpunit / CRM / Contact / Page / DedupeExceptionTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * Test class for CRM_Contact_Page_DedupeException BAO
30 *
31 * @package CiviCRM
32 * @group headless
33 */
34 class CRM_Contact_Page_DedupeExceptionTest extends CiviUnitTestCase {
35
36 /**
37 * Sets up the fixture, for example, opens a network connection.
38 * This method is called before a test is executed.
39 */
40 protected function setUp() {
41 parent::setUp();
42 }
43
44 /**
45 * Tears down the fixture, for example, closes a network connection.
46 *
47 * This method is called after a test is executed.
48 */
49 protected function tearDown() {
50 parent::tearDown();
51 }
52
53 public function testGetDedupeExceptions() {
54 $contact1 = $this->individualCreate();
55 $contact2 = $this->individualCreate();
56 $exception = $this->callAPISuccess('Exception', 'create', [
57 'contact_id1' => $contact1,
58 'contact_id2' => $contact2,
59 ]);
60 $page = new CRM_Contact_Page_DedupeException();
61 $totalitems = civicrm_api3('Exception', "getcount", []);
62 $params = [
63 'total' => $totalitems,
64 'rowCount' => CRM_Utils_Pager::ROWCOUNT,
65 'status' => ts('Dedupe Exceptions %%StatusMessage%%'),
66 'buttonBottom' => 'PagerBottomButton',
67 'buttonTop' => 'PagerTopButton',
68 'pageID' => $page->get(CRM_Utils_Pager::PAGE_ID),
69 ];
70 $page->_pager = new CRM_Utils_Pager($params);
71 $exceptions = $page->getExceptions();
72 $expectedArray = [
73 $exception['id'] => [
74 'id' => $exception['id'],
75 'contact_id1.display_name' => 'Mr. Anthony Anderson II',
76 'contact_id2.display_name' => 'Mr. Anthony Anderson II',
77 'contact_id1' => $contact1,
78 'contact_id2' => $contact2,
79 ],
80 ];
81 $this->assertEquals($expectedArray, $exceptions);
82 }
83
84 }