Advertisement
Guest User

Untitled

a guest
Mar 20th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. <?php
  2. /** the function under test */
  3.   public function set($key, $value)
  4.   {
  5.     file_put_contents(
  6.       $key,
  7.       '<?php return ' . var_export($value, true) . ';'
  8.     );
  9.   }
  10.  
  11. /** a single test to check that the $key is used as filename */
  12.  
  13.   /**
  14.    * @requires extension uopz
  15.    */
  16.   public function testSetUsesKeyAsFileNameToPersistCacheIn()
  17.   {
  18.     uopz_backup('file_put_contents');
  19.     $that = $this;
  20.     uopz_function(
  21.       'file_put_contents',
  22.       function(
  23.         $filename,
  24.         $flags = false,
  25.         $context = null,
  26.         $offset = -1
  27.         //$maxlen = null
  28.       ) use ($that) {
  29.         $that->assertSame(
  30.           $filename,
  31.           'testFileName'
  32.         );
  33.       }
  34.     );
  35.     uopz_restore('file_put_contents');
  36.  
  37.     $this->cache->set('testFileName', 'test');
  38.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement