當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectManager::getConstructArguments方法代碼示例

本文整理匯總了PHP中Magento\Framework\TestFramework\Unit\Helper\ObjectManager::getConstructArguments方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectManager::getConstructArguments方法的具體用法?PHP ObjectManager::getConstructArguments怎麽用?PHP ObjectManager::getConstructArguments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\TestFramework\Unit\Helper\ObjectManager的用法示例。


在下文中一共展示了ObjectManager::getConstructArguments方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 protected function setUp()
 {
     $this->registry = $this->getMock('Magento\\Framework\\Registry');
     $this->scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $resource = $this->getMockBuilder('\\Magento\\Log\\Model\\Resource\\Log')->setMethods(['clean', 'getIdFieldName'])->disableOriginalConstructor()->getMock();
     $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id'));
     $resource->expects($this->any())->method('clean')->will($this->returnSelf());
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $arguments = $this->objectManagerHelper->getConstructArguments('Magento\\Log\\Model\\Log', ['registry' => $this->registry, 'scopeConfig' => $this->scopeConfig, 'resource' => $resource]);
     $this->log = $this->objectManagerHelper->getObject('Magento\\Log\\Model\\Log', $arguments);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:11,代碼來源:LogTest.php

示例2: 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\\ResourceModel\\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);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:VisitorTest.php

示例3: setUp

 public function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $className = 'Magento\\MediaStorage\\Helper\\File\\Storage';
     $arguments = $this->objectManager->getConstructArguments($className);
     /** @var \Magento\Framework\App\Helper\Context $context */
     $context = $arguments['context'];
     $this->filesystemStorageMock = $arguments['filesystemStorage'];
     $this->coreFileStorageDbMock = $arguments['coreFileStorageDb'];
     $this->storageMock = $arguments['storage'];
     $this->configMock = $context->getScopeConfig();
     $this->helper = $this->objectManager->getObject($className, $arguments);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:13,代碼來源:StorageTest.php

示例4: setUp

 protected function setUp()
 {
     $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $className = '\\Magento\\Contact\\Helper\\Data';
     $arguments = $this->objectManagerHelper->getConstructArguments($className);
     /**
      * @var \Magento\Framework\App\Helper\Context $context
      */
     $context = $arguments['context'];
     $this->scopeConfigMock = $context->getScopeConfig();
     $this->customerSessionMock = $arguments['customerSession'];
     $this->customerViewHelperMock = $arguments['customerViewHelper'];
     $this->helper = $this->objectManagerHelper->getObject($className, $arguments);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:14,代碼來源:DataTest.php

示例5: 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(['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(['getId', '__sleep', '__wakeup'])->getMock();
     $store->expects($this->exactly(2))->method('getId')->will($this->returnValue(1));
     $storeManager = $this->getMock('Magento\\Store\\Model\\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\\Store\\Model\\StoreManagerInterface')->will($this->returnValue($storeManager));
     $this->controller = $this->objectManagerHelper->getObject('Magento\\GoogleShopping\\Controller\\Adminhtml\\Googleshopping\\Items\\MassAdd', $this->controllerArguments);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:16,代碼來源:MassAddTest.php

示例6: setUp

    protected function setUp()
    {
        $this->rssManager = $this->getMock('Magento\Rss\Model\RssManager', ['getProvider'], [], '', false);
        $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');
        $this->rssFactory = $this->getMock('Magento\Rss\Model\RssFactory', ['create'], [], '', false);

        $request = $this->getMock('Magento\Framework\App\RequestInterface');
        $request->expects($this->once())->method('getParam')->with('type')->will($this->returnValue('rss_feed'));

        $this->response = $this->getMockBuilder('Magento\Framework\App\ResponseInterface')
            ->setMethods(['setHeader', 'setBody', 'sendResponse'])
            ->disableOriginalConstructor()->getMock();

        $objectManagerHelper = new ObjectManagerHelper($this);
        $controllerArguments = $objectManagerHelper->getConstructArguments(
            'Magento\Rss\Controller\Adminhtml\Feed\Index',
            [
                'rssManager' => $this->rssManager,
                'scopeConfig' => $this->scopeConfigInterface,
                'rssFactory' => $this->rssFactory,
                'request' => $request,
                'response' => $this->response
            ]
        );
        $objectManager = $controllerArguments['context']->getObjectManager();
        $urlInterface = $this->getMock('Magento\Backend\Model\UrlInterface');
        $objectManager->expects($this->at(0))->method('get')->with('Magento\Backend\Model\UrlInterface')
            ->will($this->returnValue($urlInterface));
        $this->controller = $objectManagerHelper->getObject(
            'Magento\Rss\Controller\Adminhtml\Feed\Index',
            $controllerArguments
        );
    }
開發者ID:nblair,項目名稱:magescotch,代碼行數:33,代碼來源:IndexTest.php

示例7: setUp

 protected function setUp()
 {
     $this->dbStorageFactoryMock = $this->getMockBuilder('Magento\\MediaStorage\\Model\\File\\Storage\\DatabaseFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $className = 'Magento\\MediaStorage\\Helper\\File\\Storage\\Database';
     $arguments = $this->objectManager->getConstructArguments($className, ['dbStorageFactory' => $this->dbStorageFactoryMock]);
     /** @var \Magento\Framework\App\Helper\Context $context */
     $context = $arguments['context'];
     $mediaDirMock = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $mediaDirMock->expects($this->any())->method('getAbsolutePath')->will($this->returnValue('media-dir'));
     $this->filesystemMock = $arguments['filesystem'];
     $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::MEDIA)->will($this->returnValue($mediaDirMock));
     $this->fileStorageMock = $arguments['fileStorage'];
     $this->configMock = $context->getScopeConfig();
     $this->helper = $this->objectManager->getObject($className, $arguments);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:16,代碼來源:DatabaseTest.php

示例8: setUp

 protected function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $arguments = $objectManagerHelper->getConstructArguments('Magento\\CatalogWidget\\Model\\Rule\\Condition\\Combine');
     $this->conditionFactory = $this->getMockBuilder('\\Magento\\CatalogWidget\\Model\\Rule\\Condition\\ProductFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $arguments['conditionFactory'] = $this->conditionFactory;
     $this->condition = $objectManagerHelper->getObject('Magento\\CatalogWidget\\Model\\Rule\\Condition\\Combine', $arguments);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:8,代碼來源:CombineTest.php

示例9: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     $className = '\\Henhed\\Piwik\\Model\\Tracker';
     $objectManager = new ObjectManager($this);
     $arguments = $objectManager->getConstructArguments($className, ['actionFactory' => $this->getMock('Henhed\\Piwik\\Model\\Tracker\\ActionFactory', ['create'], [], '', false)]);
     $this->_tracker = $objectManager->getObject($className, $arguments);
     $this->_actionFactory = $arguments['actionFactory'];
 }
開發者ID:henkelund,項目名稱:magento2-henhed-piwik,代碼行數:13,代碼來源:TrackerTest.php

示例10: setUp

 protected function setUp()
 {
     $this->stockRegistry = $this->getMock('Magento\\CatalogInventory\\Model\\StockRegistry', [], [], '', false);
     $this->stockItemData = $this->getMock('Magento\\CatalogInventory\\Model\\Stock\\Item', [], [], '', false);
     $this->stockRegistry->expects($this->any())->method('getStockItem')->with($this->productId, 10)->will($this->returnValue($this->stockItemData));
     $objectManagerHelper = new ObjectManagerHelper($this);
     $carrierArgs = $objectManagerHelper->getConstructArguments('Magento\\Shipping\\Model\\Carrier\\AbstractCarrierOnline', ['stockRegistry' => $this->stockRegistry, 'xmlSecurity' => new \Magento\Framework\Xml\Security()]);
     $this->carrier = $this->getMockBuilder('Magento\\Shipping\\Model\\Carrier\\AbstractCarrierOnline')->setConstructorArgs($carrierArgs)->setMethods(['getConfigData', '_doShipmentRequest', 'collectRates'])->getMock();
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:9,代碼來源:AbstractCarrierOnlineTest.php

示例11: setUp

 protected function setUp()
 {
     $this->buyer = $this->getMockBuilder('Tobai\\BuyerReview\\Model\\Buyer')->disableOriginalConstructor()->getMock();
     $this->generalConfig = $this->getMockBuilder('Tobai\\BuyerReview\\Model\\Config\\General')->disableOriginalConstructor()->getMock();
     $this->reviewCollectionFactory = $this->getMockBuilder('Magento\\Review\\Model\\ResourceModel\\Review\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $objectManagerHelper = new ObjectManagerHelper($this);
     $listViewConstructorArgs = $objectManagerHelper->getConstructArguments('Tobai\\BuyerReview\\Block\\Review\\ListView', ['buyer' => $this->buyer, 'generalConfig' => $this->generalConfig, 'collectionFactory' => $this->reviewCollectionFactory]);
     $this->listView = $this->getMockBuilder('Tobai\\BuyerReview\\Block\\Review\\ListView')->setConstructorArgs($listViewConstructorArgs)->setMethods(['getProductId', 'getReviewsCollection'])->getMock();
 }
開發者ID:ytorbyk,項目名稱:magento2-buyer-review,代碼行數:9,代碼來源:ListViewTest.php

示例12: 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(['create'])->getMock();
     $orderFactory->expects($this->once())->method('create')->will($this->returnValue($orderMock));
     $messageCollectionFactory = $this->getMockBuilder('Magento\\Framework\\Message\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $quoteRepository = $this->getMock('\\Magento\\Quote\\Api\\CartRepositoryInterface');
     $appState = $this->getMock('\\Magento\\Framework\\App\\State', [], [], '', false);
     $appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true));
     $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $request->expects($this->any())->method('getHttpHost')->will($this->returnValue([]));
     $constructArguments = $this->_helper->getConstructArguments('Magento\\Checkout\\Model\\Session', ['request' => $request, 'orderFactory' => $orderFactory, 'messageCollectionFactory' => $messageCollectionFactory, 'quoteRepository' => $quoteRepository, '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());
     }
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:24,代碼來源:SessionTest.php

示例13: testGetVariablesOptionArrayWithGroup

 public function testGetVariablesOptionArrayWithGroup()
 {
     $origOptions = [['value' => 'VAL', 'label' => 'LBL']];
     $transformedOptions = ['label' => __('Custom Variables'), 'value' => [['value' => '{{customVar code=VAL}}', 'label' => __('%1', 'LBL')]]];
     $collectionMock = $this->getMockBuilder('\\Magento\\Variable\\Model\\ResourceModel\\Variable\\Collection')->disableOriginalConstructor()->getMock();
     $collectionMock->expects($this->any())->method('toOptionArray')->willReturn($origOptions);
     $mockVariable = $this->getMock('Magento\\Variable\\Model\\Variable', ['getCollection'], $this->objectManager->getConstructArguments('Magento\\Variable\\Model\\Variable'));
     $mockVariable->expects($this->any())->method('getCollection')->willReturn($collectionMock);
     $this->assertEquals($transformedOptions, $mockVariable->getVariablesOptionArray(true));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:10,代碼來源:VariableTest.php

示例14: setUp

 protected function setUp()
 {
     $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $className = 'Magento\\Sitemap\\Helper\\Data';
     $arguments = $objectManagerHelper->getConstructArguments($className);
     /** @var \Magento\Framework\App\Helper\Context $context */
     $context = $arguments['context'];
     $this->scopeConfig = $context->getScopeConfig();
     $this->data = $objectManagerHelper->getObject($className, $arguments);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:10,代碼來源:DataTest.php

示例15: testLoadWithFilter

 public function testLoadWithFilter()
 {
     /** @var $collection \PHPUnit_Framework_MockObject_MockObject */
     $constructArgs = $this->objectManager->getConstructArguments('Magento\\Reports\\Model\\ResourceModel\\Quote\\Item\\Collection');
     $constructArgs['eventManager'] = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $resourceMock = $this->getMock('\\Magento\\Quote\\Model\\ResourceModel\\Quote', [], [], '', false);
     $resourceMock->expects($this->any())->method('getConnection')->willReturn($this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false));
     $constructArgs['resource'] = $resourceMock;
     $productResourceMock = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', [], [], '', false);
     $constructArgs['productResource'] = $productResourceMock;
     $orderResourceMock = $this->getMock('\\Magento\\Sales\\Model\\ResourceModel\\Order\\Collection', [], [], '', false);
     $constructArgs['orderResource'] = $orderResourceMock;
     $collection = $this->getMock('Magento\\Reports\\Model\\ResourceModel\\Quote\\Item\\Collection', ['_beforeLoad', '_renderFilters', '_renderOrders', '_renderLimit', 'printLogQuery', 'getData', '_setIsLoaded', 'setConnection', '_initSelect', 'getTable', 'getItems', 'getOrdersData'], $constructArgs);
     //load()
     $collection->expects($this->once())->method('_beforeLoad')->willReturnSelf();
     $collection->expects($this->once())->method('_renderFilters')->willReturnSelf();
     $collection->expects($this->once())->method('_renderOrders')->willReturnSelf();
     $collection->expects($this->once())->method('_renderLimit')->willReturnSelf();
     $collection->expects($this->once())->method('printLogQuery')->willReturnSelf();
     $collection->expects($this->once())->method('getData')->willReturn(null);
     $collection->expects($this->once())->method('_setIsLoaded')->willReturnSelf();
     //productLoad()
     $productAttributeMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], [], '', false);
     $priceAttributeMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], [], '', false);
     $productResourceMock->expects($this->once())->method('getConnection')->willReturn($connectionMock);
     $productResourceMock->expects($this->any())->method('getAttribute')->willReturnMap([['name', $productAttributeMock], ['price', $priceAttributeMock]]);
     $productResourceMock->expects($this->once())->method('getSelect')->willReturn($this->selectMock);
     $eavEntity = $this->getMock('Magento\\Eav\\Model\\Entity\\AbstractEntity', [], [], '', false);
     $eavEntity->expects($this->once())->method('getLinkField')->willReturn('entity_id');
     $productResourceMock->expects($this->once())->method('getEntity')->willReturn($eavEntity);
     $this->selectMock->expects($this->once())->method('reset')->willReturnSelf();
     $this->selectMock->expects($this->once())->method('from')->willReturnSelf();
     $this->selectMock->expects($this->once())->method('useStraightJoin')->willReturnSelf();
     $this->selectMock->expects($this->exactly(2))->method('joinInner')->willReturnSelf();
     $collection->expects($this->once())->method('getOrdersData')->willReturn([]);
     $productAttributeMock->expects($this->once())->method('getBackend')->willReturnSelf();
     $priceAttributeMock->expects($this->once())->method('getBackend')->willReturnSelf();
     $connectionMock->expects($this->once())->method('fetchAssoc')->willReturn([1, 2, 3]);
     //_afterLoad()
     $collection->expects($this->once())->method('getItems')->willReturn([]);
     $collection->loadWithFilter();
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:43,代碼來源:CollectionTest.php


注:本文中的Magento\Framework\TestFramework\Unit\Helper\ObjectManager::getConstructArguments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。