本文整理匯總了PHP中Magento\TestFramework\Helper\ObjectManager::getConstructArguments方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectManager::getConstructArguments方法的具體用法?PHP ObjectManager::getConstructArguments怎麽用?PHP ObjectManager::getConstructArguments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\TestFramework\Helper\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::getConstructArguments方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
protected function setUp()
{
$this->registry = $this->getMock('Magento\\Framework\\Registry');
$this->session = $this->getMockBuilder('Magento\\Customer\\Model\\Session')->disableOriginalConstructor()->setMethods(['getSessionId', 'getVisitorData', 'setVisitorData'])->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->resource = $this->getMockBuilder('Magento\\Customer\\Model\\Resource\\Visitor')->setMethods(['beginTransaction', '__sleep', '__wakeup', 'getIdFieldName', 'save', 'addCommitCallback', 'commit', 'clean'])->disableOriginalConstructor()->getMock();
$this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id'));
$this->resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf());
$arguments = $this->objectManagerHelper->getConstructArguments('Magento\\Customer\\Model\\Visitor', ['registry' => $this->registry, 'session' => $this->session, 'resource' => $this->resource]);
$this->visitor = $this->objectManagerHelper->getObject('Magento\\Customer\\Model\\Visitor', $arguments);
}
示例2: setUp
protected function setUp()
{
$this->notificationInterface = $this->getMock('Magento\\Framework\\Notification\\NotifierInterface');
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->controllerArguments = $this->objectManagerHelper->getConstructArguments('Magento\\GoogleShopping\\Controller\\Adminhtml\\Googleshopping\\Items\\MassAdd', ['notifier' => $this->notificationInterface]);
$this->flag = $this->getMockBuilder('Magento\\GoogleShopping\\Model\\Flag')->disableOriginalConstructor()->setMethods(array('loadSelf', '__sleep', '__wakeup', 'isLocked', 'lock', 'unlock'))->getMock();
$this->flag->expects($this->once())->method('loadSelf')->will($this->returnSelf());
$this->flag->expects($this->once())->method('isLocked')->will($this->returnValue(false));
$store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(array('getId', '__sleep', '__wakeup'))->getMock();
$store->expects($this->exactly(2))->method('getId')->will($this->returnValue(1));
$storeManager = $this->getMock('Magento\\Framework\\StoreManagerInterface');
$storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store));
$this->controllerArguments['context']->getObjectManager()->expects($this->at(0))->method('get')->with('Magento\\GoogleShopping\\Model\\Flag')->will($this->returnValue($this->flag));
$this->controllerArguments['context']->getObjectManager()->expects($this->at(1))->method('get')->with('Magento\\Framework\\StoreManagerInterface')->will($this->returnValue($storeManager));
$this->controller = $this->objectManagerHelper->getObject('Magento\\GoogleShopping\\Controller\\Adminhtml\\Googleshopping\\Items\\MassAdd', $this->controllerArguments);
}
示例3: testGetLastRealOrder
/**
* @param int|null $orderId
* @param int|null $incrementId
* @param \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject $orderMock
* @dataProvider getLastRealOrderDataProvider
*/
public function testGetLastRealOrder($orderId, $incrementId, $orderMock)
{
$orderFactory = $this->getMockBuilder('Magento\\Sales\\Model\\OrderFactory')->disableOriginalConstructor()->setMethods(array('create'))->getMock();
$orderFactory->expects($this->once())->method('create')->will($this->returnValue($orderMock));
$messageCollectionFactory = $this->getMockBuilder('Magento\\Framework\\Message\\CollectionFactory')->disableOriginalConstructor()->getMock();
$quoteFactory = $this->getMockBuilder('Magento\\Sales\\Model\\QuoteFactory')->disableOriginalConstructor()->getMock();
$appState = $this->getMock('\\Magento\\Framework\\App\\State', array(), array(), '', false);
$appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true));
$request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', array(), array(), '', false);
$request->expects($this->any())->method('getHttpHost')->will($this->returnValue(array()));
$constructArguments = $this->_helper->getConstructArguments('Magento\\Checkout\\Model\\Session', array('request' => $request, 'orderFactory' => $orderFactory, 'messageCollectionFactory' => $messageCollectionFactory, 'quoteFactory' => $quoteFactory, 'storage' => new \Magento\Framework\Session\Storage()));
$this->_session = $this->_helper->getObject('Magento\\Checkout\\Model\\Session', $constructArguments);
$this->_session->setLastRealOrderId($orderId);
$this->assertSame($orderMock, $this->_session->getLastRealOrder());
if ($orderId == $incrementId) {
$this->assertSame($orderMock, $this->_session->getLastRealOrder());
}
}
示例4: testGetAssociatedProductIdsNonCached
public function testGetAssociatedProductIdsNonCached()
{
$args = $this->objectHelper->getConstructArguments('\\Magento\\GroupedProduct\\Model\\Product\\Type\\Grouped', []);
/** @var \Magento\GroupedProduct\Model\Product\Type\Grouped $model */
$model = $this->getMock('\\Magento\\GroupedProduct\\Model\\Product\\Type\\Grouped', ['getAssociatedProducts'], $args);
$associatedProduct = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
$model->expects($this->once())->method('getAssociatedProducts')->with($this->product)->will($this->returnValue([$associatedProduct]));
$associatedId = 9384;
$key = '_cache_instance_associated_product_ids';
$associatedIds = [$associatedId];
$associatedProduct->expects($this->once())->method('getId')->will($this->returnValue($associatedId));
$this->product->expects($this->once())->method('hasData')->with($key)->will($this->returnValue(false));
$this->product->expects($this->once())->method('setData')->with($key, $associatedIds);
$this->product->expects($this->once())->method('getData')->with($key)->will($this->returnValue($associatedIds));
$this->assertEquals($associatedIds, $model->getAssociatedProductIds($this->product));
}