Пример #1
0
 public function testDispatchCurrentStoreCurrency()
 {
     $this->httpContextMock->expects($this->at(0))->method('setValue')->with(StoreManagerInterface::CONTEXT_STORE, 'custom_store', 'default');
     /** Make sure that current currency is taken from current store if no value is provided in session */
     $this->httpContextMock->expects($this->at(1))->method('setValue')->with(Context::CONTEXT_CURRENCY, self::CURRENCY_CURRENT_STORE, self::CURRENCY_DEFAULT);
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }
Пример #2
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Invalid store parameter.
  */
 public function testDispatchStoreParameterIsInvalidArray()
 {
     $this->storeMock->expects($this->never())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_DEFAULT));
     $this->storeMock->expects($this->never())->method('getCode')->willReturn('default');
     $this->currentStoreMock->expects($this->never())->method('getCode')->willReturn('custom_store');
     $store = ['some' => ['code' => 500]];
     $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue($store));
     $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock);
 }
Пример #3
0
 /**
  * Test aroundDispatch
  */
 public function testAroundDispatch()
 {
     $this->storeManagerMock->expects($this->exactly(2))->method('getWebsite')->will($this->returnValue($this->websiteMock));
     $this->websiteMock->expects($this->exactly(2))->method('getDefaultStore')->will($this->returnValue($this->storeMock));
     $this->storeMock->expects($this->once())->method('getDefaultCurrency')->will($this->returnValue($this->currencyMock));
     $this->storeMock->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('storeCookie'));
     $this->currencyMock->expects($this->once())->method('getCode')->will($this->returnValue('UAH'));
     $this->sessionMock->expects($this->once())->method('getCurrencyCode')->will($this->returnValue('UAH'));
     $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue('default'));
     $this->httpContextMock->expects($this->atLeastOnce())->method('setValue')->will($this->returnValueMap([[\Magento\Core\Helper\Data::CONTEXT_CURRENCY, 'UAH', 'UAH', $this->httpContextMock], [\Magento\Core\Helper\Data::CONTEXT_STORE, 'default', 'default', $this->httpContextMock]]));
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }