Merge in 5.26
[civicrm-core.git] / tests / phpunit / CRM / Utils / Cache / SqlGroupTest.php
index 77f31a26b4ae73ae67d15c8ab566e416f69d2de6..68d1ac325032bf4368bc68c52d35f0b685c461ea 100644 (file)
@@ -5,6 +5,7 @@
  * @group headless
  */
 class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase {
+
   public function setUp() {
     parent::setUp();
   }
@@ -17,14 +18,14 @@ class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase {
    * Add and remove two items from the same cache instance.
    */
   public function testSameInstance() {
-    $a = new CRM_Utils_Cache_SqlGroup(array(
+    $a = new CRM_Utils_Cache_SqlGroup([
       'group' => 'testSameInstance',
-    ));
+    ]);
     $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_cache WHERE group_name = "testSameInstance"');
-    $fooValue = array('whiz' => 'bang', 'bar' => 2);
+    $fooValue = ['whiz' => 'bang', 'bar' => 2];
     $a->set('foo', $fooValue);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_cache WHERE group_name = "testSameInstance"');
-    $this->assertEquals($a->get('foo'), array('whiz' => 'bang', 'bar' => 2));
+    $this->assertEquals($a->get('foo'), ['whiz' => 'bang', 'bar' => 2]);
 
     $barValue = 45.78;
     $a->set('bar', $barValue);
@@ -42,20 +43,20 @@ class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase {
    * Add item to one cache instance then read with another.
    */
   public function testTwoInstance() {
-    $a = new CRM_Utils_Cache_SqlGroup(array(
+    $a = new CRM_Utils_Cache_SqlGroup([
       'group' => 'testTwoInstance',
-    ));
-    $fooValue = array('whiz' => 'bang', 'bar' => 3);
+    ]);
+    $fooValue = ['whiz' => 'bang', 'bar' => 3];
     $a->set('foo', $fooValue);
     $getValue = $a->get('foo');
-    $expectValue = array('whiz' => 'bang', 'bar' => 3);
+    $expectValue = ['whiz' => 'bang', 'bar' => 3];
     $this->assertEquals($getValue, $expectValue);
 
-    $b = new CRM_Utils_Cache_SqlGroup(array(
+    $b = new CRM_Utils_Cache_SqlGroup([
       'group' => 'testTwoInstance',
       'prefetch' => FALSE,
-    ));
-    $this->assertEquals($b->get('foo'), array('whiz' => 'bang', 'bar' => 3));
+    ]);
+    $this->assertEquals($b->get('foo'), ['whiz' => 'bang', 'bar' => 3]);
   }
 
   /**
@@ -63,30 +64,35 @@ class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase {
    */
   public function testPrefetch() {
     // 1. put data in cache
-    $a = new CRM_Utils_Cache_SqlGroup(array(
+    $a = new CRM_Utils_Cache_SqlGroup([
       'group' => 'testPrefetch',
       'prefetch' => FALSE,
-    ));
-    $fooValue = array('whiz' => 'bang', 'bar' => 4);
+    ]);
+    $fooValue = ['whiz' => 'bang', 'bar' => 4];
     $a->set('foo', $fooValue);
-    $this->assertEquals($a->get('foo'), array('whiz' => 'bang', 'bar' => 4));
+    $this->assertEquals($a->get('foo'), ['whiz' => 'bang', 'bar' => 4]);
 
     // 2. see what happens when prefetch is TRUE
-    $b = new CRM_Utils_Cache_SqlGroup(array(
+    $b = new CRM_Utils_Cache_SqlGroup([
       'group' => 'testPrefetch',
       'prefetch' => TRUE,
-    ));
-    $this->assertEquals($fooValue, $b->getFromFrontCache('foo')); // should work b/c value was prefetched
-    $this->assertEquals($fooValue, $b->get('foo')); // should work b/c value was prefetched
+    ]);
+    // should work b/c value was prefetched
+    $this->assertEquals($fooValue, $b->getFromFrontCache('foo'));
+    // should work b/c value was prefetched
+    $this->assertEquals($fooValue, $b->get('foo'));
 
     // 3. see what happens when prefetch is FALSE
-    $c = new CRM_Utils_Cache_SqlGroup(array(
+    $c = new CRM_Utils_Cache_SqlGroup([
       'group' => 'testPrefetch',
       'prefetch' => FALSE,
-    ));
-    $this->assertEquals(NULL, $c->getFromFrontCache('foo')); // should be NULL b/c value was NOT prefetched
-    $this->assertEquals($fooValue, $c->get('foo')); // should work b/c value is fetched on demand
-    $this->assertEquals($fooValue, $c->getFromFrontCache('foo')); // should work b/c value was fetched on demand
+    ]);
+    // should be NULL b/c value was NOT prefetched
+    $this->assertEquals(NULL, $c->getFromFrontCache('foo'));
+    // should work b/c value is fetched on demand
+    $this->assertEquals($fooValue, $c->get('foo'));
+    // should work b/c value was fetched on demand
+    $this->assertEquals($fooValue, $c->getFromFrontCache('foo'));
   }
 
 }