Example #1
0
 /**
  * @param string $error
  * @param float $summaryQty
  * @param array $totals
  * @param array $result
  *
  * @dataProvider dataProviderGetResponseData
  */
 public function testGetResponseData($error, $summaryQty, $totals, $result)
 {
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $quoteMock->expects($this->any())->method('getTotals')->willReturn($totals);
     $this->cartMock->expects($this->any())->method('getSummaryQty')->willReturn($summaryQty);
     $this->cartMock->expects($this->any())->method('getQuote')->willReturn($quoteMock);
     $this->checkoutHelperMock->expects($this->any())->method('formatPrice')->willReturnArgument(0);
     $this->assertEquals($result, $this->sidebar->getResponseData($error));
 }
Example #2
0
 /**
  * Compile JSON response
  *
  * @param string $error
  * @return Http
  */
 protected function jsonResponse($error = '')
 {
     $response = $this->sidebar->getResponseData($error);
     if (empty($error)) {
         $resultPage = $this->resultPageFactory->create();
         $block = $resultPage->getLayout()->getBlock('minicart.content')->toHtml();
         $response['content'] = $block;
     }
     return $this->getResponse()->representJson($this->jsonHelper->jsonEncode($response));
 }
Example #3
0
 /**
  * @param string $error
  * @param array $result
  *
  * @dataProvider dataProviderGetResponseData
  */
 public function testGetResponseData($error, $result)
 {
     $this->assertEquals($result, $this->sidebar->getResponseData($error));
 }
Example #4
0
 /**
  * Compile JSON response
  *
  * @param string $error
  * @return Http
  */
 protected function jsonResponse($error = '')
 {
     $response = $this->sidebar->getResponseData($error);
     return $this->getResponse()->representJson($this->jsonHelper->jsonEncode($response));
 }