3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
28 * Verify that CRM_Utils_Cache_ArrayDecorator complies with PSR-16.
32 class E2E_Cache_ArrayDecoratorTest
extends E2E_Cache_CacheTestCase
{
35 * @var CRM_Utils_Cache_Interface
39 public function createSimpleCache() {
40 return new CRM_Utils_Cache_ArrayDecorator(
41 $this->a
= CRM_Utils_Cache
::create([
42 'name' => 'e2e array-dec test',
43 'type' => ['ArrayCache'],
48 public function testDoubleLifeWithDelete() {
49 $this->assertFalse($this->a
->has('foo'));
50 $this->assertEquals('dfl-1', $this->a
->get('foo', 'dfl-1'));
52 $this->cache
->set('foo', 100);
54 $this->assertTrue($this->a
->has('foo'));
55 $this->assertEquals(100, $this->a
->get('foo', 'dfl-1')[1]);
57 $this->cache
->set('foo', 200);
59 $this->assertTrue($this->a
->has('foo'));
60 $this->assertEquals(200, $this->a
->get('foo', 'dfl-1')[1]);
62 $this->cache
->delete('foo');
64 $this->assertFalse($this->a
->has('foo'));
65 $this->assertEquals('dfl-1', $this->a
->get('foo', 'dfl-1'));
68 public function testDoubleLifeWithClear() {
69 $this->assertFalse($this->a
->has('foo'));
70 $this->assertEquals('dfl-1', $this->a
->get('foo', 'dfl-1'));
72 $this->cache
->set('foo', 100);
74 $this->assertTrue($this->a
->has('foo'));
75 $this->assertEquals(100, $this->a
->get('foo', 'dfl-1')[1]);
77 $this->cache
->clear();
79 $this->assertFalse($this->a
->has('foo'));
80 $this->assertEquals('dfl-1', $this->a
->get('foo', 'dfl-1'));