public function testExecute() { $this->_getTreeBlock(); $testHtml = '<div>Some test html</div>'; $this->chooserBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($testHtml)); $this->resultRaw->expects($this->once())->method('setContents')->with($testHtml); $this->controller->executeInternal(); }
public function testExecute() { $this->_getTreeBlock(); $testHtml = '<div>Some test html</div>'; $this->chooserBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($testHtml)); $this->responseMock->expects($this->once())->method('setBody')->with($this->equalTo($testHtml)); $this->controller->execute(); }
public function testExecute() { $this->_getTreeBlock(); $testCategoryId = 1; $this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue($testCategoryId)); $categoryMock = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false); $categoryMock->expects($this->once())->method('load')->will($this->returnValue($categoryMock)); $categoryMock->expects($this->once())->method('getId')->will($this->returnValue($testCategoryId)); $this->objectManagerMock->expects($this->once())->method('create')->with($this->equalTo('Magento\\Catalog\\Model\\Category'))->will($this->returnValue($categoryMock)); $this->chooserBlockMock->expects($this->once())->method('setSelectedCategories')->will($this->returnValue($this->chooserBlockMock)); $testHtml = '<div>Some test html</div>'; $this->chooserBlockMock->expects($this->once())->method('getTreeJson')->will($this->returnValue($testHtml)); $this->resultJson->expects($this->once())->method('setJsonData')->with($testHtml)->willReturnSelf(); $this->controller->execute(); }
/** * Get JSON of a tree node or an associative array * * @param \Magento\Framework\Data\Tree\Node|array $node * @param int $level * @return string */ protected function _getNodeJson($node, $level = 0) { $item = parent::_getNodeJson($node, $level); $item['level'] = $node->getLevel(); return $item; }