Detect/use APCu properly
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / MemoizedCallableTest.php
index 519c8c3..881f5e1 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 /**
  * A MemoizedCallable subclass that stores function return values
- * in an instance property rather than APC.
+ * in an instance property rather than APC or APCu.
  */
 class ArrayBackedMemoizedCallable extends MemoizedCallable {
-       public $cache = [];
+       private $cache = [];
 
        protected function fetchResult( $key, &$success ) {
                if ( array_key_exists( $key, $this->cache ) ) {
@@ -44,7 +44,7 @@ class MemoizedCallableTest extends PHPUnit_Framework_TestCase {
         * Consecutive calls to the memoized callable with the same arguments
         * should result in just one invocation of the underlying callable.
         *
-        * @requires function apc_store
+        * @requires function apc_store/apcu_store
         */
        public function testCallableMemoized() {
                $observer = $this->getMock( 'stdClass', [ 'computeSomething' ] );
@@ -112,6 +112,11 @@ class MemoizedCallableTest extends PHPUnit_Framework_TestCase {
                        $this->readAttribute( $a, 'callableName' ),
                        $this->readAttribute( $b, 'callableName' )
                );
+
+               $c = new ArrayBackedMemoizedCallable( function () {
+                       return rand();
+               } );
+               $this->assertEquals( $c->invokeArgs(), $c->invokeArgs(), 'memoized random' );
        }
 
        /**