protected function setUp()
 {
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->setMethods(['setRenderedBlock', 'getTemplate', 'setTemplate'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->setMethods(['getBlock', 'getChildName'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->layoutMock->expects($this->any())->method('getBlock')->will($this->returnValue($this->blockMock));
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\Context')->setMethods(['getLayout'])->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->layoutMock));
     $this->renderList = $objectManagerHelper->getObject('Magento\\Framework\\View\\Element\\RendererList', ['context' => $this->contextMock]);
 }
Beispiel #2
0
    public function testToHtml()
    {
        $this->context->expects($this->once())->method('getEventManager')->will($this->returnValue($this->getMockForAbstractClass('\\Magento\\Framework\\Event\\ManagerInterface')));
        $this->context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($this->getMockForAbstractClass('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')));
        $this->config->expects($this->once())->method('getBaseConfig')->will($this->returnValue('the config data'));
        $object = new Config($this->context, $this->config, $this->fileManager, $this->pageConfig);
        $html = $object->toHtml();
        $expectedFormat = <<<expected
<script type="text/javascript">
the config data</script>
expected;
        $this->assertStringMatchesFormat($expectedFormat, $html);
    }
 public function setUp()
 {
     $this->context = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', [], [], '', false);
     $this->escaper = $this->getMock('Magento\\Framework\\Escaper', [], [], '', false);
     $this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper);
     $localeDate = $this->getMockForAbstractClass('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface', [], '', false);
     $this->context->expects($this->once())->method('getLocaleDate')->willReturn($localeDate);
     $this->urlBuilder = $this->getMockForAbstractClass('Magento\\Framework\\UrlInterface', [], '', false);
     $this->context->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilder);
     $this->layout = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false);
     $this->context->expects($this->once())->method('getLayout')->willReturn($this->layout);
     $this->eventManager = $this->getMockForAbstractClass('Magento\\Framework\\Event\\ManagerInterface', [], '', false);
     $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager);
     $this->scopeConfig = $this->getMockForAbstractClass('Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], '', false);
     $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig);
     $this->cache = $this->getMockForAbstractClass('Magento\\Framework\\App\\CacheInterface', [], '', false);
     $this->context->expects($this->once())->method('getCache')->willReturn($this->cache);
     $this->agreementCollection = $this->getMockBuilder('Magento\\Paypal\\Model\\ResourceModel\\Billing\\Agreement\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->helper = $this->getMock('Magento\\Paypal\\Helper\\Data', [], [], '', false);
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->block = $objectManager->getObject('Magento\\Paypal\\Block\\Billing\\Agreements', ['context' => $this->context, 'agreementCollection' => $this->agreementCollection, 'helper' => $this->helper]);
 }