Exemplo n.º 1
0
 /**
  * @return void
  */
 public function testGetPageHeading()
 {
     $title = 'some title';
     $this->pageTitleMock->expects($this->once())->method('getShortHeading')->willReturn($title);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->assertEquals($title, $this->htmlTitle->getPageHeading());
 }
Exemplo n.º 2
0
 public function testProcess()
 {
     $generatorContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Generator\\Context')->disableOriginalConstructor()->getMock();
     $this->title->expects($this->any())->method('set')->with()->will($this->returnSelf());
     $structureMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config\\Structure')->disableOriginalConstructor()->getMock();
     $readerContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock();
     $readerContextMock->expects($this->any())->method('getPageConfigStructure')->willReturn($structureMock);
     $structureMock->expects($this->once())->method('processRemoveAssets');
     $structureMock->expects($this->once())->method('processRemoveElementAttributes');
     $assets = ['remoteCss' => ['src' => 'file-url', 'src_type' => 'url', 'media' => "all", 'content_type' => 'css'], 'remoteLink' => ['src' => 'file-url', 'src_type' => 'url', 'media' => "all"], 'name' => ['src' => 'file-path', 'ie_condition' => 'lt IE 7', 'media' => "print", 'content_type' => 'css']];
     $this->pageConfigMock->expects($this->at(0))->method('addRemotePageAsset')->with('remoteCss', 'css', ['attributes' => ['media' => 'all']]);
     $this->pageConfigMock->expects($this->at(1))->method('addRemotePageAsset')->with('remoteLink', Head::VIRTUAL_CONTENT_TYPE_LINK, ['attributes' => ['media' => 'all']]);
     $this->pageConfigMock->expects($this->once())->method('addPageAsset')->with('name', ['attributes' => ['media' => 'print'], 'ie_condition' => 'lt IE 7']);
     $structureMock->expects($this->once())->method('getAssets')->will($this->returnValue($assets));
     $title = 'Page title';
     $structureMock->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $this->pageConfigMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->title));
     $metadata = ['name1' => 'content1', 'name2' => 'content2'];
     $structureMock->expects($this->once())->method('getMetadata')->will($this->returnValue($metadata));
     $this->pageConfigMock->expects($this->exactly(2))->method('setMetadata')->withConsecutive(['name1', 'content1'], ['name2', 'content2']);
     $elementAttributes = [PageConfig::ELEMENT_TYPE_BODY => ['body_attr_1' => 'body_value_1', 'body_attr_2' => 'body_value_2'], PageConfig::ELEMENT_TYPE_HTML => ['html_attr_1' => 'html_attr_1']];
     $structureMock->expects($this->once())->method('getElementAttributes')->will($this->returnValue($elementAttributes));
     $this->pageConfigMock->expects($this->exactly(3))->method('setElementAttribute')->withConsecutive([PageConfig::ELEMENT_TYPE_BODY, 'body_attr_1', 'body_value_1'], [PageConfig::ELEMENT_TYPE_BODY, 'body_attr_2', 'body_value_2'], [PageConfig::ELEMENT_TYPE_HTML, 'html_attr_1', 'html_attr_1']);
     $this->assertEquals($this->headGenerator, $this->headGenerator->process($readerContextMock, $generatorContextMock));
 }
Exemplo n.º 3
0
 public function testExecuteInternal()
 {
     $this->viewMock->expects($this->once())->method('getPage')->willReturn($this->pageMock);
     $this->pageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->once())->method('prepend')->willReturnSelf();
     $this->assertNull($this->object->executeInternal());
 }
Exemplo n.º 4
0
 public function testAppendPrepend()
 {
     $value = 'title';
     $prepend = 'prepend_title';
     $append = 'append_title';
     $expected = 'prepend_title / title / append_title';
     $this->title->set($value);
     $this->title->prepend($prepend);
     $this->title->append($append);
     $this->assertEquals($expected, $this->title->get());
 }
Exemplo n.º 5
0
 /**
  * @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
  */
 public function testExecute()
 {
     $this->prepareExecute();
     $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Customer::customer_manage');
     $this->resultPageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->once())->method('prepend')->with('Customers');
     $this->resultPageMock->expects($this->atLeastOnce())->method('addBreadcrumb')->withConsecutive(['Customers', 'Customers'], ['Manage Customers', 'Manage Customers']);
     $this->sessionMock->expects($this->once())->method('unsCustomerData');
     $this->assertInstanceOf('Magento\\Framework\\View\\Result\\Page', $this->indexController->execute());
 }
Exemplo n.º 6
0
 public function testExecute()
 {
     $this->menuMock->expects($this->once())->method('getParentItems')->willReturn([$this->menuItemMock]);
     $this->titleMock->expects($this->atLeastOnce())->method('prepend');
     $this->pageConfigMock->expects($this->atLeastOnce())->method('getTitle')->willReturn($this->titleMock);
     $this->pageMock->expects($this->atLeastOnce())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->blockMock->expects($this->atLeastOnce())->method('addLink');
     $this->blockMock->expects($this->once())->method('setActive');
     $this->blockMock->expects($this->once())->method('getMenuModel')->willReturn($this->menuMock);
     $this->layoutMock->expects($this->atLeastOnce())->method('getBlock')->willReturn($this->blockMock);
     $this->viewMock->expects($this->once())->method('loadLayout')->willReturnSelf();
     $this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
     $this->viewMock->expects($this->atLeastOnce())->method('getPage')->willReturn($this->pageMock);
     $this->action->executeInternal();
 }
Exemplo n.º 7
0
 /**
  * @covers \Magento\Email\Controller\Adminhtml\Email\Template\Index::execute
  */
 public function testExecute()
 {
     $this->prepareExecute();
     $this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
     $this->layoutMock->expects($this->at(0))->method('getBlock')->with('menu')->will($this->returnValue($this->menuBlockMock));
     $this->menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf());
     $this->menuBlockMock->expects($this->any())->method('getParentItems')->will($this->returnValue([]));
     $this->viewMock->expects($this->once())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->once())->method('prepend')->with('Email Templates');
     $this->layoutMock->expects($this->at(1))->method('getBlock')->with('breadcrumbs')->will($this->returnValue($this->breadcrumbsBlockMock));
     $this->breadcrumbsBlockMock->expects($this->any())->method('addLink')->willReturnSelf();
     $this->assertNull($this->indexController->execute());
 }
Exemplo n.º 8
0
    /**
     * @covers \Magento\Sales\Controller\Adminhtml\Order\View::executeInternal
     */
    public function testExecute()
    {
        $id = 111;
        $titlePart = '#111';
        $this->initOrder();
        $this->initOrderSuccess($id);
        $this->prepareRedirect();
        $this->initAction();

        $this->resultPageMock->expects($this->atLeastOnce())
            ->method('getConfig')
            ->willReturn($this->pageConfigMock);
        $this->pageConfigMock->expects($this->atLeastOnce())
            ->method('getTitle')
            ->willReturn($this->pageTitleMock);
        $this->orderMock->expects($this->atLeastOnce())
            ->method('getIncrementId')
            ->willReturn($id);
        $this->pageTitleMock->expects($this->exactly(2))
            ->method('prepend')
            ->withConsecutive(
                ['Orders'],
                [$titlePart]
            )
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Page',
            $this->viewAction->executeInternal()
        );
    }
Exemplo n.º 9
0
 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $data = ['comment' => 'comment'];
     $result = 'result-html';
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $blockMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\View\\Comments', ['toHtml'], [], '', false);
     $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId);
     $this->requestMock->expects($this->once())->method('getPost')->with('comment')->will($this->returnValue($data));
     $this->titleMock->expects($this->once())->method('prepend');
     $this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap([['id', null, $shipmentId], ['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipment], ['tracking', null, $tracking]]));
     $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment);
     $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking);
     $this->shipmentLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->shipmentMock));
     $this->shipmentMock->expects($this->once())->method('addComment');
     $this->shipmentSenderMock->expects($this->once())->method('send');
     $this->shipmentMock->expects($this->once())->method('save');
     $this->viewInterfaceMock->expects($this->once())->method('loadLayout')->with(false);
     $this->viewInterfaceMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($blockMock));
     $blockMock->expects($this->once())->method('toHtml')->will($this->returnValue($result));
     $this->responseMock->expects($this->once())->method('setBody')->with($result);
     $this->assertNull($this->controller->execute());
 }
Exemplo n.º 10
0
 /**
  * @covers \Magento\Email\Controller\Adminhtml\Email\Template\Edit::execute
  */
 public function testExecuteEdit()
 {
     $this->requestMock->expects($this->any())->method('getParam')->with('id')->willReturn(1);
     $this->registryMock->expects($this->atLeastOnce())->method('registry')->willReturnMap([['email_template', false], ['current_email_template', false]]);
     $this->pageTitleMock->expects($this->any())->method('prepend')->willReturnMap([['Email Templates', $this->returnSelf()], ['My Template', $this->returnSelf()]]);
     $this->breadcrumbsBlockMock->expects($this->any())->method('addLink')->willReturnMap([['Transactional Emails', 'Transactional Emails', null, $this->returnSelf()], ['Edit Template', 'Edit System Template', null, $this->returnSelf()]]);
     $this->assertNull($this->editController->execute());
 }
Exemplo n.º 11
0
 public function testRenderTitle()
 {
     $title = 'some_title';
     $expected = "<title>some_title</title>" . "\n";
     $this->pageConfigMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->titleMock));
     $this->titleMock->expects($this->once())->method('get')->will($this->returnValue($title));
     $this->assertEquals($expected, $this->renderer->renderTitle());
 }
Exemplo n.º 12
0
 public function testRenderTitle()
 {
     $title = 'some_title';
     $expected = "<title>some_title</title>" . "\n";
     $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock);
     $this->titleMock->expects($this->once())->method('get')->willReturn($title);
     $this->escaperMock->expects($this->once())->method('escapeHtml')->willReturnArgument(0);
     $this->assertEquals($expected, $this->renderer->renderTitle());
 }
Exemplo n.º 13
0
 public function testConstructMethod()
 {
     $data = [];
     $customerId = 25;
     $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $statuses = ['pending', 'processing', 'comlete'];
     $this->orderConfig->expects($this->once())->method('getVisibleOnFrontStatuses')->will($this->returnValue($statuses));
     $orderCollection = $this->getMock('Magento\\Sales\\Model\\ResourceModel\\Order\\Collection', ['addFieldToSelect', 'addFieldToFilter', 'setOrder'], [], '', false, false);
     $this->context->expects($this->any())->method('getPageConfig')->willReturn($this->pageConfig);
     $orderCollection->expects($this->at(0))->method('addFieldToSelect')->with($this->equalTo('*'))->will($this->returnSelf());
     $orderCollection->expects($this->at(1))->method('addFieldToFilter')->with('status', $this->equalTo(['in' => $statuses]))->will($this->returnSelf());
     $orderCollection->expects($this->at(2))->method('setOrder')->with('created_at', 'desc')->will($this->returnSelf());
     $this->orderCollectionFactoryInterface->expects($this->atLeastOnce())->method('create')->will($this->returnValue($orderCollection));
     $this->pageConfig->expects($this->atLeastOnce())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->atLeastOnce())->method('set')->willReturnSelf();
     $this->model = new \Magento\Sales\Block\Order\History($this->context, $this->orderCollectionFactory, $this->customerSession, $this->orderConfig, $data);
     $this->assertEquals($orderCollection, $this->model->getOrders());
 }
Exemplo n.º 14
0
    /**
     * Run test execute method
     */
    public function testExecute()
    {
        $orderId = 1;
        $shipmentId = 1;
        $shipment = [];
        $tracking = [];
        $incrementId = '10000001';
        $comeFrom = true;

        $this->loadShipment($orderId, $shipmentId, $shipment, $tracking, $comeFrom, $this->shipmentMock);
        $this->shipmentMock->expects($this->once())->method('getIncrementId')->willReturn($incrementId);
        $this->resultPageFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultPageMock);

        $layoutMock = $this->getMock('Magento\Framework\View\Layout', ['getBlock', '__wakeup'], [], '', false);
        $this->resultPageMock->expects($this->once())
            ->method('getLayout')
            ->willReturn($layoutMock);
        $layoutMock->expects($this->once())
            ->method('getBlock')
            ->with('sales_shipment_view')
            ->willReturn($this->blockMock);
        $this->blockMock->expects($this->once())
            ->method('updateBackButtonUrl')
            ->with($comeFrom)
            ->willReturnSelf();

        $this->resultPageMock->expects($this->once())
            ->method('setActiveMenu')
            ->with('Magento_Sales::sales_shipment')
            ->willReturnSelf();
        $this->resultPageMock->expects($this->atLeastOnce())
            ->method('getConfig')
            ->willReturn($this->pageConfigMock);
        $this->pageConfigMock->expects($this->atLeastOnce())
            ->method('getTitle')
            ->willReturn($this->pageTitleMock);
        $this->pageTitleMock->expects($this->exactly(2))
            ->method('prepend')
            ->withConsecutive(
                ['Shipments'],
                ["#" . $incrementId]
            )
            ->willReturnSelf();

        $this->assertEquals($this->resultPageMock, $this->controller->executeInternal());
    }
Exemplo n.º 15
0
 public function testExecuteNoPopup()
 {
     $attributesData = ['frontend_label' => ''];
     $this->request->expects($this->any())->method('getParam')->willReturnMap([['attribute_id', null, null], ['attribute', null, $attributesData], ['popup', null, false]]);
     $this->objectManagerMock->expects($this->any())->method('create')->with('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute')->willReturn($this->eavAttribute);
     $this->objectManagerMock->expects($this->any())->method('get')->with('Magento\\Backend\\Model\\Session')->willReturn($this->session);
     $this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf();
     $this->eavAttribute->expects($this->once())->method('addData')->with($attributesData)->willReturnSelf();
     $this->registry->expects($this->any())->method('register')->with('entity_attribute', $this->eavAttribute);
     $this->resultPage->expects($this->any())->method('addBreadcrumb')->willReturnSelf();
     $this->resultPage->expects($this->once())->method('setActiveMenu')->with('Magento_Catalog::catalog_attributes_attributes')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
     $this->resultPage->expects($this->once())->method('getLayout')->willReturn($this->layout);
     $this->resultPageFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->resultPage);
     $this->pageConfig->expects($this->any())->method('getTitle')->willReturn($this->pageTitle);
     $this->pageTitle->expects($this->any())->method('prepend')->willReturnSelf();
     $this->eavAttribute->expects($this->any())->method('getName')->willReturn(null);
     $this->layout->expects($this->once())->method('getBlock')->willReturn($this->blockTemplate);
     $this->blockTemplate->expects($this->any())->method('setIsPopup')->willReturnSelf();
     $this->assertSame($this->resultPage, $this->editController->execute());
 }
Exemplo n.º 16
0
 /**
  *  test execute method
  */
 public function testExecute()
 {
     $this->requestMock->expects($this->exactly(4))->method('getParam')->will($this->returnValueMap([['order_id', null, 'order_id'], ['creditmemo_id', null, 'creditmemo_id'], ['creditmemo', null, 'creditmemo'], ['invoice_id', null, 'invoice_id']]));
     $this->creditmemoLoaderMock->expects($this->once())->method('setOrderId')->with($this->equalTo('order_id'));
     $this->creditmemoLoaderMock->expects($this->once())->method('setCreditmemoId')->with($this->equalTo('creditmemo_id'));
     $this->creditmemoLoaderMock->expects($this->once())->method('setCreditmemo')->with($this->equalTo('creditmemo'));
     $this->creditmemoLoaderMock->expects($this->once())->method('setInvoiceId')->with($this->equalTo('invoice_id'));
     $this->creditmemoLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->creditmemoMock));
     $this->creditmemoMock->expects($this->exactly(2))->method('getInvoice')->will($this->returnValue($this->invoiceMock));
     $this->invoiceMock->expects($this->once())->method('getIncrementId')->will($this->returnValue('invoice-increment-id'));
     $this->titleMock->expects($this->exactly(2))->method('prepend')->will($this->returnValueMap([['Credit Memos', null], ['New Memo for #invoice-increment-id', null], ['item-title', null]]));
     $this->objectManagerMock->expects($this->once())->method('get')->with($this->equalTo('Magento\\Backend\\Model\\Session'))->will($this->returnValue($this->backendSessionMock));
     $this->backendSessionMock->expects($this->once())->method('getCommentText')->with($this->equalTo(true))->will($this->returnValue('comment'));
     $this->creditmemoMock->expects($this->once())->method('setCommentText')->with($this->equalTo('comment'));
     $this->resultPageMock->expects($this->any())->method('getConfig')->will($this->returnValue($this->pageConfigMock));
     $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock);
     $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order')->willReturnSelf();
     $this->resultPageMock->expects($this->atLeastOnce())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Page', $this->controller->execute());
 }