示例#1
0
 public function addMethods(array $methods)
 {
     foreach ($methods as $key => $default) {
         if ($default instanceof \Closure) {
             $this->mock->expects($key)->andCallback($default);
         } else {
             $this->mock->expects($key)->andReturn($default);
         }
     }
 }
示例#2
0
 public function testMultipleCalls()
 {
     $this->object->expects('abc')->with(1)->andReturn(2);
     $this->object->expects('abc')->with(2)->andReturn(3);
     $this->object->expects('abc')->andReturn(4);
     $this->assertEquals(2, $this->object->abc(1));
     $this->assertEquals(3, $this->object->abc(2));
     $this->assertEquals(4, $this->object->abc());
     $this->assertEquals(4, $this->object->abc('aa'));
 }
 /**
  * Test load method key not found exception
  */
 public function testLoadKeyNotFound()
 {
     $this->memoryCacheMock->hasKey(self::KEY)->once()->andReturn(false);
     $this->memoryCacheMock->load(self::KEY)->never();
     $this->memoryCacheMock->freeze();
     $this->fileCacheMock->hasKey(self::KEY)->once()->andReturn(false);
     $this->fileCacheMock->load(self::KEY)->never();
     $this->fileCacheMock->freeze();
     $smartCache = new SmartCache($this->fileCacheMock, $this->memoryCacheMock);
     $this->setExpectedException('Hadamcik\\SmartCache\\KeyNotFoundException');
     $smartCache->load(self::KEY);
 }
示例#4
0
 /**
  * Sets mock expectations for called method getDir in FileCache
  * @return void
  */
 private function getDir($path = self::PATH)
 {
     $this->directoryMock->getPath()->atLeastOnce()->andReturn(self::PATH);
 }