Exemple #1
0
 /**
  * @expectedException Mockista\MockException
  * @expectedExceptionCode 3
  * @expectedExceptionMessage Expected method unnamed::abc() should be called no more than twice but called 3 times.
  */
 public function testCollectNoMoreThanBad()
 {
     $this->object->expects('abc')->noMoreThan(2);
     $this->object->abc();
     $this->object->abc();
     $this->object->abc();
     $this->object->assertExpectations();
 }
 /**
  * Test hasKey method
  */
 public function testHasKey()
 {
     $this->setDir();
     $this->getDir();
     $this->directoryMock->freeze();
     $this->filemanagerMock->fileExists($this->getCachedFilePath())->once()->andReturn(true);
     $this->filemanagerMock->freeze();
     $fileCache = new FileCache(self::PATH, $this->filemanagerMock);
     $this->assertTrue($fileCache->hasKey(self::KEY));
     $this->directoryMock->assertExpectations();
     $this->filemanagerMock->assertExpectations();
 }
 /**
  * Test load method correctly by file cache
  */
 public function testLoadFileCache()
 {
     $this->memoryCacheMock->hasKey(self::KEY)->once()->andReturn(false);
     $this->memoryCacheMock->load(self::KEY)->never();
     $this->memoryCacheMock->freeze();
     $this->fileCacheMock->hasKey(self::KEY)->once()->andReturn(true);
     $this->fileCacheMock->load(self::KEY)->once()->andReturn(self::VALUE);
     $this->fileCacheMock->freeze();
     $smartCache = new SmartCache($this->fileCacheMock, $this->memoryCacheMock);
     $this->assertSame(self::VALUE, $smartCache->load(self::KEY));
     $this->memoryCacheMock->assertExpectations();
     $this->fileCacheMock->assertExpectations();
 }