Skip to content

Commit

Permalink
MAGETWO-83289: [Backport 2.3] magento#11825: Generate new FormKey and…
Browse files Browse the repository at this point in the history
… replace for oldRequestParams Wishlist magento#12042

 - fixed unit test
  • Loading branch information
Volodymyr Kublytskyi committed Dec 1, 2017
1 parent 3b442ad commit cc1602f
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
use Magento\Customer\Model\Session;
use Magento\Framework\App\PageCache\FormKey as CookieFormKey;
use Magento\Framework\Data\Form\FormKey as DataFormKey;
use Magento\Framework\Event\Observer;
use Magento\PageCache\Observer\FlushFormKey;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;

class CustomerFlushFormKeyTest extends TestCase
{
const CLOSURE_VALUE = 'CLOSURE';

/**
* @var CookieFormKey | MockObject
*/
Expand All @@ -32,11 +31,6 @@ class CustomerFlushFormKeyTest extends TestCase
*/
private $dataFormKey;

/**
* @var \Closure
*/
private $closure;

protected function setUp()
{

Expand All @@ -55,10 +49,6 @@ protected function setUp()
->disableOriginalConstructor()
->setMethods(['getBeforeRequestParams', 'setBeforeRequestParams'])
->getMock();

$this->closure = function () {
return static::CLOSURE_VALUE;
};
}

/**
Expand All @@ -74,6 +64,7 @@ public function testAroundFlushFormKey(
$getFormKeyTimes,
$setBeforeParamsTimes
) {
$observerDto = new Observer();
$observer = new FlushFormKey($this->cookieFormKey, $this->dataFormKey);
$plugin = new CustomerFlushFormKey($this->customerSession, $this->dataFormKey);

Expand All @@ -91,7 +82,11 @@ public function testAroundFlushFormKey(
->method('setBeforeRequestParams')
->with($beforeParams);

$plugin->aroundExecute($observer, $this->closure, $observer);
$proceed = function ($observerDto) use ($observer) {
return $observer->execute($observerDto);
};

$plugin->aroundExecute($observer, $proceed, $observerDto);
}

/**
Expand Down

0 comments on commit cc1602f

Please sign in to comment.