54 $this->request = $this->createMock(\
Magento\Framework\
App\RequestInterface::class);
55 $this->factory = $this->createPartialMock(\
Magento\Catalog\Model\ProductFactory::class, [
'create']);
56 $this->registry = $this->createMock(\
Magento\Framework\Registry::class);
57 $this->resultFactoryMock = $this->getMockBuilder(\
Magento\Framework\Controller\ResultFactory::class)
58 ->disableOriginalConstructor()
60 $this->resultLayoutMock = $this->getMockBuilder(\
Magento\Framework\View\Result\Layout::class)
61 ->disableOriginalConstructor()
64 $this->resultFactoryMock->expects($this->any())
67 ->willReturn($this->resultLayoutMock);
69 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
70 $this->context = $this->objectManager->getObject(
73 'request' => $this->request,
74 'resultFactory' => $this->resultFactoryMock
77 $this->action = $this->objectManager->getObject(
78 \
Magento\GroupedProduct\Controller\Adminhtml\Edit\Popup::class,
80 'context' => $this->context,
81 'factory' => $this->factory,
82 'registry' => $this->registry
94 \
Magento\Catalog\Model\Product::class,
95 [
'setStoreId',
'setTypeId',
'setData',
'__wakeup']
98 $this->request->expects($this->at(0))->method(
'getParam')->with(
'id')->will($this->returnValue(
$productId));
99 $this->factory->expects($this->once())->method(
'create')->will($this->returnValue(
$product));
100 $this->request->expects(
112 $this->request->expects($this->at(2))->method(
'getParam')->with(
'type')->will($this->returnValue($typeId));
113 $product->expects($this->once())->method(
'setTypeId')->with($typeId);
114 $product->expects($this->once())->method(
'setData')->with(
'_edit_mode',
true);
115 $this->request->expects($this->at(3))->method(
'getParam')->with(
'set')->will($this->returnValue($setId));
116 $this->registry->expects($this->once())->method(
'register')->with(
'current_product',
$product);
118 $this->assertSame($this->resultLayoutMock, $this->action->execute());
127 $product = $this->createPartialMock(
128 \
Magento\Catalog\Model\Product::class,
129 [
'setStoreId',
'setTypeId',
'setData',
'load',
'__wakeup']
132 $this->request->expects($this->at(0))->method(
'getParam')->with(
'id')->will($this->returnValue(
$productId));
133 $this->factory->expects($this->once())->method(
'create')->will($this->returnValue(
$product));
134 $this->request->expects(
145 $this->request->expects($this->at(2))->method(
'getParam')->with(
'type')->will($this->returnValue($typeId));
146 $product->expects($this->never())->method(
'setTypeId');
147 $product->expects($this->once())->method(
'setData')->with(
'_edit_mode',
true);
149 $this->request->expects($this->at(3))->method(
'getParam')->with(
'set')->will($this->returnValue($setId));
150 $this->registry->expects($this->once())->method(
'register')->with(
'current_product',
$product);
152 $this->assertSame($this->resultLayoutMock, $this->action->execute());