/**
  * Consecutive calls to the memoized callable with the same arguments
  * should result in just one invocation of the underlying callable.
  *
  * @requires function apc_store
  */
 public function testCallableMemoized()
 {
     $observer = $this->getMock('stdClass', array('computeSomething'));
     $observer->expects($this->once())->method('computeSomething')->will($this->returnValue('ok'));
     $memoized = new ArrayBackedMemoizedCallable(array($observer, 'computeSomething'));
     // First invocation -- delegates to $observer->computeSomething()
     $this->assertEquals('ok', $memoized->invoke());
     // Second invocation -- returns memoized result
     $this->assertEquals('ok', $memoized->invoke());
 }
 /**
  * Closure names should be distinct.
  */
 public function testMemoizedClosure()
 {
     $a = new MemoizedCallable(function () {
         return 'a';
     });
     $b = new MemoizedCallable(function () {
         return 'b';
     });
     $this->assertEquals($a->invokeArgs(), 'a');
     $this->assertEquals($b->invokeArgs(), 'b');
     $this->assertNotEquals($this->readAttribute($a, 'callableName'), $this->readAttribute($b, 'callableName'));
     $c = new ArrayBackedMemoizedCallable(function () {
         return rand();
     });
     $this->assertEquals($c->invokeArgs(), $c->invokeArgs(), 'memoized random');
 }