コード例 #1
0
ファイル: MockBuilder.php プロジェクト: saimons/mockista
 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
ファイル: MockistaTest.php プロジェクト: saimons/mockista
 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'));
 }
コード例 #3
0
 /**
  * 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);
 }