Example #1
0
 /**
  * @param $cacheReturnValue
  * @param $expectedResult
  *
  * @dataProvider testLockActionDataProvider
  */
 public function testLockAction($cacheReturnValue, $expectedResult)
 {
     $ttl = 33;
     $cacheMock = $this->getMockForAbstractClass(\Magelight\Cache\AdapterAbstract::class, [], '', false, false, true, ['setNx']);
     $adapterPoolMock = $this->getMock(\Magelight\Cache\AdapterPool::class, [], [], '', false);
     \Magelight\Cache\AdapterPool::forgeMock($adapterPoolMock);
     $adapterPoolMock->expects($this->any())->method('getAdapter')->will($this->returnValue($cacheMock));
     $cacheMock->expects($this->any())->method('setNx')->with(md5(serialize([]) . '_lock'), 1, $ttl)->will($this->returnValue($cacheReturnValue));
     $this->controller->init();
     $this->assertEquals($expectedResult, $this->controller->lockCurrentAction($ttl));
 }