Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 /**
  * @covers Magento\RecurringPayment\Block\Checkout\Onepage\Success::_prepareLastRecurringPayments
  */
 public function testToHtmlPreparesRecurringPayments()
 {
     $checkoutSessionArgs = $this->objectManager->getConstructArguments('Magento\\Checkout\\Model\\Session', array('storage' => new \Magento\Framework\Session\Storage('checkout')));
     $checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', array('getLastRecurringPaymentIds'), $checkoutSessionArgs);
     $checkoutSession->expects($this->once())->method('getLastRecurringPaymentIds')->will($this->returnValue(array(1, 2, 3)));
     $collection = $this->getMock('Magento\\RecurringPayment\\Model\\Resource\\Payment\\Collection', array('addFieldToFilter'), array(), '', false);
     $collection->expects($this->once())->method('addFieldToFilter')->with('payment_id', array('in' => array(1, 2, 3)))->will($this->returnValue(array()));
     $recurringPaymentCollectionFactory = $this->getMock('Magento\\RecurringPayment\\Model\\Resource\\Payment\\CollectionFactory', array('create'), array(), '', false);
     $recurringPaymentCollectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection));
     /** @var \Magento\Checkout\Block\Onepage\Success $block */
     $block = $this->objectManager->getObject('Magento\\RecurringPayment\\Block\\Checkout\\Onepage\\Success', array('checkoutSession' => $checkoutSession, 'recurringPaymentCollectionFactory' => $recurringPaymentCollectionFactory));
     $this->assertEquals('', $block->toHtml());
 }
Exemplo n.º 4
0
 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\\Refresh', ['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));
     $this->flag->expects($this->once())->method('unlock')->will($this->returnSelf());
     /** @var \PHPUnit_Framework_MockObject_MockObject $objectMananger */
     $objectMananger = $this->controllerArguments['context']->getObjectManager();
     $objectMananger->expects($this->at(0))->method('get')->with('Magento\\GoogleShopping\\Model\\Flag')->will($this->returnValue($this->flag));
     $this->controller = $this->objectManagerHelper->getObject('Magento\\GoogleShopping\\Controller\\Adminhtml\\Googleshopping\\Items\\Refresh', $this->controllerArguments);
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 /**
  * @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());
     }
 }
Exemplo n.º 8
0
 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]);
     $this->carrier = $this->getMockBuilder('Magento\\Shipping\\Model\\Carrier\\AbstractCarrierOnline')->setConstructorArgs($carrierArgs)->setMethods(['getConfigData', '_doShipmentRequest', 'collectRates'])->getMock();
 }
Exemplo n.º 9
0
 protected function setUp()
 {
     $this->rule = $this->getMock('Magento\\CatalogWidget\\Model\\Rule', [], [], '', false);
     $this->response = $this->getMockBuilder('\\Magento\\Framework\\App\\ResponseInterface')->setMethods(['setBody', 'sendResponse'])->disableOriginalConstructor()->getMock();
     $this->response->expects($this->once())->method('setBody')->will($this->returnSelf());
     $objectManagerHelper = new ObjectManagerHelper($this);
     $arguments = $objectManagerHelper->getConstructArguments('Magento\\CatalogWidget\\Controller\\Adminhtml\\Product\\Widget\\Conditions', ['rule' => $this->rule, 'response' => $this->response]);
     $this->request = $arguments['context']->getRequest();
     $this->objectManager = $arguments['context']->getObjectManager();
     $this->controller = $objectManagerHelper->getObject('Magento\\CatalogWidget\\Controller\\Adminhtml\\Product\\Widget\\Conditions', $arguments);
 }
Exemplo n.º 10
0
 /**
  * Test for method exportItem()
  *
  * @covers \Magento\CustomerImportExport\Model\Export\Address::exportItem
  */
 public function testExportItem()
 {
     $writer = $this->getMockForAbstractClass('Magento\\ImportExport\\Model\\Export\\Adapter\\AbstractAdapter', array(), '', false, false, true, array('writeRow'));
     $writer->expects($this->once())->method('writeRow')->will($this->returnCallback(array($this, 'validateWriteRow')));
     $this->_model->setWriter($writer);
     $this->_model->setParameters(array());
     $arguments = $this->_objectManager->getConstructArguments('Magento\\Framework\\Model\\AbstractModel');
     $arguments['data'] = $this->_addressData;
     $item = $this->getMockForAbstractClass('Magento\\Framework\\Model\\AbstractModel', $arguments);
     $this->_model->exportItem($item);
 }
Exemplo n.º 11
0
 /**
  * Create mock of attribute collection, so it can be used for tests
  *
  * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Data\Collection
  */
 protected function _createAttrCollectionMock()
 {
     $entityFactory = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', [], [], '', false);
     $attributeCollection = $this->getMock('Magento\\Framework\\Data\\Collection', ['getEntityTypeCode'], [$entityFactory]);
     foreach ($this->_attributes as $attributeData) {
         $arguments = $this->_objectManagerMock->getConstructArguments('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [$this->getMock('Magento\\Framework\\Model\\Context', [], [], '', false, false), $this->getMock('Magento\\Framework\\Registry'), $this->getMock('Magento\\Core\\Helper\\Data', [], [], '', false, false), $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false, false), $this->getMock('Magento\\Eav\\Model\\Entity\\TypeFactory', [], [], '', false), $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false, false), $this->getMock('Magento\\Eav\\Model\\Resource\\Helper', [], [], '', false, false), $this->getMock('Magento\\Framework\\Validator\\UniversalFactory', [], [], '', false, false)]);
         $arguments['data'] = $attributeData;
         $attribute = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', $arguments, '', true, true, true, ['_construct', 'getBackend']);
         $attribute->expects($this->any())->method('getBackend')->will($this->returnSelf());
         $attribute->expects($this->any())->method('getTable')->will($this->returnValue($attributeData['table']));
         $attributeCollection->addItem($attribute);
     }
     return $attributeCollection;
 }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
0
 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));
 }
Exemplo n.º 14
0
 protected function setUp()
 {
     $this->collectionFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product\\CollectionFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->visibility = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Visibility')->setMethods(['getVisibleInCatalogIds'])->disableOriginalConstructor()->getMock();
     $this->httpContext = $this->getMock('Magento\\Framework\\App\\Http\\Context');
     $this->builder = $this->getMock('Magento\\Rule\\Model\\Condition\\Sql\\Builder', [], [], '', false);
     $this->rule = $this->getMock('Magento\\CatalogWidget\\Model\\Rule', [], [], '', false);
     $this->widgetConditionsHelper = $this->getMock('Magento\\Widget\\Helper\\Conditions');
     $this->storeManager = $this->getMock('\\Magento\\Framework\\Store\\StoreManagerInterface');
     $this->design = $this->getMock('\\Magento\\Framework\\View\\DesignInterface');
     $objectManagerHelper = new ObjectManagerHelper($this);
     $arguments = $objectManagerHelper->getConstructArguments('Magento\\CatalogWidget\\Block\\Product\\ProductsList', ['productCollectionFactory' => $this->collectionFactory, 'catalogProductVisibility' => $this->visibility, 'httpContext' => $this->httpContext, 'sqlBuilder' => $this->builder, 'rule' => $this->rule, 'conditionsHelper' => $this->widgetConditionsHelper, 'storeManager' => $this->storeManager, 'design' => $this->design]);
     $this->request = $arguments['context']->getRequest();
     $this->layout = $arguments['context']->getLayout();
     $this->productsList = $objectManagerHelper->getObject('Magento\\CatalogWidget\\Block\\Product\\ProductsList', $arguments);
 }
Exemplo n.º 15
0
 public function setUp()
 {
     $this->registry = $this->getMock('Magento\\Framework\\Registry');
     $this->sessionManagerInterface = $this->getMock('Magento\\Framework\\Session\\SessionManagerInterface');
     $this->storeManagerInterface = $this->getMock('Magento\\Framework\\Store\\StoreManagerInterface');
     $this->header = $this->getMock('Magento\\Framework\\HTTP\\Header', [], [], '', false);
     $this->remoteAddress = $this->getMock('Magento\\Framework\\HTTP\\PhpEnvironment\\RemoteAddress', [], [], '', false);
     $this->serverAddress = $this->getMock('Magento\\Framework\\HTTP\\PhpEnvironment\\ServerAddress', [], [], '', false);
     $this->dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime');
     $store = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false, false);
     $this->storeManagerInterface->expects($this->any())->method('getStore')->will($this->returnValue($store));
     $this->resource = $this->getMockBuilder('Magento\\Customer\\Model\\Resource\\Visitor')->setMethods(['beginTransaction', '__sleep', '__wakeup', 'getIdFieldName', 'save', 'addCommitCallback', 'commit'])->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id'));
     $this->resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf());
     $objectManagerHelper = new ObjectManagerHelper($this);
     $arguments = $objectManagerHelper->getConstructArguments('Magento\\Log\\Model\\Visitor', ['registry' => $this->registry, 'session' => $this->sessionManagerInterface, 'storeManager' => $this->storeManagerInterface, 'httpHeader' => $this->header, 'remoteAddress' => $this->remoteAddress, 'serverAddress' => $this->serverAddress, 'dateTime' => $this->dateTime, 'resource' => $this->resource]);
     $this->visitor = $objectManagerHelper->getObject('Magento\\Log\\Model\\Visitor', $arguments);
 }