Merge pull request #17253 from mattwire/utf8convertblocksize
[civicrm-core.git] / tests / phpunit / CRM / Core / BAO / PrevNextCacheTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Class CRM_Core_BAO_PrevNextCacheTest
14 * @group headless
15 */
16 class CRM_Core_BAO_PrevNextCacheTest extends CiviUnitTestCase {
17
18 public function testFlipData() {
19 $dao = new CRM_Core_BAO_PrevNextCache();
20 $dao->entity_id1 = 1;
21 $dao->entity_id2 = 2;
22 $dao->data = serialize([
23 'srcID' => 1,
24 'srcName' => 'Ms. Meliissa Mouse II',
25 'dstID' => 2,
26 'dstName' => 'Mr. Maurice Mouse II',
27 'weight' => 20,
28 'canMerge' => TRUE,
29 ]);
30 $dao->save();
31 $dao = new CRM_Core_BAO_PrevNextCache();
32 $dao->id = 1;
33 CRM_Core_BAO_PrevNextCache::flipPair([1], 0);
34 $dao->find(TRUE);
35 $this->assertEquals(1, $dao->entity_id1);
36 $this->assertEquals(2, $dao->entity_id2);
37 $this->assertEquals(serialize([
38 'srcName' => 'Mr. Maurice Mouse II',
39 'dstID' => 1,
40 'dstName' => 'Ms. Meliissa Mouse II',
41 'weight' => 20,
42 'canMerge' => TRUE,
43 'srcID' => 2,
44 ]), $dao->data);
45
46 $this->quickCleanup(['civicrm_prevnext_cache']);
47 }
48
49 }