Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Test.php
Go to the documentation of this file.
1 <?php
27 #require_once 'Zend/Cache/Backend/ExtendedInterface.php';
28 
32 #require_once 'Zend/Cache/Backend.php';
33 
41 {
47  protected $_options = array();
48 
54  protected $_directives = array();
55 
61  private $_log = array();
62 
68  private $_index = 0;
69 
76  public function __construct($options = array())
77  {
78  $this->_addLog('construct', array($options));
79  }
80 
87  public function setDirectives($directives)
88  {
89  $this->_addLog('setDirectives', array($directives));
90  }
91 
103  public function load($id, $doNotTestCacheValidity = false)
104  {
105  $this->_addLog('get', array($id, $doNotTestCacheValidity));
106 
107  if ( $id == 'false'
108  || $id == 'd8523b3ee441006261eeffa5c3d3a0a7'
109  || $id == 'e83249ea22178277d5befc2c5e2e9ace'
110  || $id == '40f649b94977c0a6e76902e2a0b43587'
111  || $id == '88161989b73a4cbfd0b701c446115a99'
112  || $id == '205fc79cba24f0f0018eb92c7c8b3ba4'
113  || $id == '170720e35f38150b811f68a937fb042d')
114  {
115  return false;
116  }
117  if ($id=='serialized') {
118  return serialize(array('foo'));
119  }
120  if ($id=='serialized2') {
121  return serialize(array('headers' => array(), 'data' => 'foo'));
122  }
123  if ( $id == '71769f39054f75894288e397df04e445' || $id == '615d222619fb20b527168340cebd0578'
124  || $id == '8a02d218a5165c467e7a5747cc6bd4b6' || $id == '648aca1366211d17cbf48e65dc570bee'
125  || $id == '4a923ef02d7f997ca14d56dfeae25ea7') {
126  return serialize(array('foo', 'bar'));
127  }
128  if ( $id == 'f53c7d912cc523d9a65834c8286eceb9') {
129  return serialize(array('foobar'));
130  }
131  return 'foo';
132  }
133 
143  public function test($id)
144  {
145  $this->_addLog('test', array($id));
146  if ($id=='false') {
147  return false;
148  }
149  if (($id=='3c439c922209e2cb0b54d6deffccd75a')) {
150  return false;
151  }
152  return 123456;
153  }
154 
167  public function save($data, $id, $tags = array(), $specificLifetime = false)
168  {
169  $this->_addLog('save', array($data, $id, $tags));
170  if (substr($id,-5)=='false') {
171  return false;
172  }
173  return true;
174  }
175 
185  public function remove($id)
186  {
187  $this->_addLog('remove', array($id));
188  if (substr($id,-5)=='false') {
189  return false;
190  }
191  return true;
192  }
193 
212  public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
213  {
214  $this->_addLog('clean', array($mode, $tags));
215  if ($mode=='false') {
216  return false;
217  }
218  return true;
219  }
220 
226  public function getLastLog()
227  {
228  return $this->_log[$this->_index - 1];
229  }
230 
236  public function getLogIndex()
237  {
238  return $this->_index;
239  }
240 
246  public function getAllLogs()
247  {
248  return $this->_log;
249  }
250 
257  {
258  return true;
259  }
260 
266  public function getIds()
267  {
268  return array(
269  'prefix_id1', 'prefix_id2'
270  );
271  }
272 
278  public function getTags()
279  {
280  return array(
281  'tag1', 'tag2'
282  );
283  }
284 
293  public function getIdsMatchingTags($tags = array())
294  {
295  if ($tags == array('tag1', 'tag2')) {
296  return array('prefix_id1', 'prefix_id2');
297  }
298 
299  return array();
300  }
301 
310  public function getIdsNotMatchingTags($tags = array())
311  {
312  if ($tags == array('tag3', 'tag4')) {
313  return array('prefix_id3', 'prefix_id4');
314  }
315 
316  return array();
317  }
318 
327  public function getIdsMatchingAnyTags($tags = array())
328  {
329  if ($tags == array('tag5', 'tag6')) {
330  return array('prefix_id5', 'prefix_id6');
331  }
332 
333  return array();
334  }
335 
341  public function getFillingPercentage()
342  {
343  return 50;
344  }
345 
357  public function getMetadatas($id)
358  {
359  return false;
360  }
361 
369  public function touch($id, $extraLifetime)
370  {
371  return true;
372  }
373 
388  public function getCapabilities()
389  {
390  return array(
391  'automatic_cleaning' => true,
392  'tags' => true,
393  'expired_read' => false,
394  'priority' => true,
395  'infinite_lifetime' => true,
396  'get_list' => true
397  );
398  }
399 
407  private function _addLog($methodName, $args)
408  {
409  $this->_log[$this->_index] = array(
410  'methodName' => $methodName,
411  'args' => $args
412  );
413  $this->_index = $this->_index + 1;
414  }
415 
416 }
save($data, $id, $tags=array(), $specificLifetime=false)
Definition: Test.php:167
$id
Definition: fieldset.phtml:14
getIdsNotMatchingTags($tags=array())
Definition: Test.php:310
_log($message, $priority=4)
Definition: Backend.php:273
__construct($options=array())
Definition: Test.php:76
getIdsMatchingTags($tags=array())
Definition: Test.php:293
setDirectives($directives)
Definition: Test.php:87
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
const CLEANING_MODE_ALL
Definition: Cache.php:72
touch($id, $extraLifetime)
Definition: Test.php:369
clean($mode=Zend_Cache::CLEANING_MODE_ALL, $tags=array())
Definition: Test.php:212
getIdsMatchingAnyTags($tags=array())
Definition: Test.php:327
load($id, $doNotTestCacheValidity=false)
Definition: Test.php:103