X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCRM%2FUtils%2FCache%2FSqlGroupTest.php;h=68d1ac325032bf4368bc68c52d35f0b685c461ea;hb=6871137ee4dda24f7ae671d73d128e97ce8e0cfa;hp=130eaa53349876bfdd7b4fa8ef66b495da4cf06c;hpb=e71360126e438a313d4ab86524a462e01e0efdfa;p=civicrm-core.git diff --git a/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php b/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php index 130eaa5334..68d1ac3250 100644 --- a/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php +++ b/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php @@ -18,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); @@ -43,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]); } /** @@ -64,29 +64,29 @@ 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, - )); + ]); // 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, - )); + ]); // should be NULL b/c value was NOT prefetched $this->assertEquals(NULL, $c->getFromFrontCache('foo')); // should work b/c value is fetched on demand