Example #1
0
 /**
  * Test render method.
  */
 public function testRender()
 {
     $arrayToRender = ['key' => 'value'];
     /** Assert that jsonEncode method in mocked helper will run once */
     $this->encoderMock->expects($this->once())->method('encode');
     $this->_restJsonRenderer->render($arrayToRender);
 }
 /**
  * @return void
  */
 public function testGetSessionCheckerJson()
 {
     $requestUrl = 'http://host/index.php/security/session/check';
     $redirectUrl = 'http://host/index.php/admin';
     $this->urlBuilder->expects($this->exactly(2))->method('getUrl')->willReturnOnConsecutiveCalls($requestUrl, $redirectUrl);
     $value = ['requestUrl' => $requestUrl, 'redirectUrl' => $redirectUrl];
     $this->jsonEncoderMock->expects($this->once())->method('encode')->with($value)->willReturn(json_encode($value));
     $this->assertEquals(json_encode($value), $this->block->getSessionCheckerJson());
 }
 public function testGetJsLayout()
 {
     /**
      * @var Item|\PHPUnit_Framework_MockObject_MockObject $itemMock
      */
     $itemMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Item')->disableOriginalConstructor()->getMock();
     $this->layoutProcessorMock->expects($this->once())->method('process')->with($this->jsLayout, $itemMock)->willReturnArgument(0);
     $this->jsonEncoderMock->expects($this->once())->method('encode')->with($this->jsLayout)->willReturnArgument(0);
     $this->model->setItem($itemMock);
     $this->assertEquals($this->jsLayout, $this->model->getJsLayout());
 }
 /**
  * Test default render format is JSON.
  * @return void
  */
 public function testRenderDefaultFormat()
 {
     /** Set undefined rendering format. */
     $_SERVER['HTTP_ACCEPT'] = 'undefined';
     /** Assert that jsonEncode method will be executed at least once. */
     $this->encoderMock->expects($this->atLeastOnce())->method('encode');
     $this->_errorProcessor->renderErrorMessage('Message');
 }
 public function testGetGiftOptionsConfigJson()
 {
     $this->compositeConfigProvider->expects($this->once())->method('getConfig')->willReturn($this->jsLayout);
     $this->jsonEncoderMock->expects($this->once())->method('encode')->with($this->jsLayout)->willReturnArgument(0);
     $this->assertEquals($this->jsLayout, $this->model->getGiftOptionsConfigJson());
 }