protected function setUp() { $this->_urlBuilder = $this->getMock('Magento\\Backend\\Model\\Url', [], [], '', false); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $constructArguments = $objectManagerHelper->getConstructArguments('Magento\\Theme\\Block\\Adminhtml\\System\\Design\\Theme\\Edit\\Tab\\Js', ['formFactory' => $this->getMock('Magento\\Framework\\Data\\FormFactory', [], [], '', false), 'objectManager' => $this->getMock('Magento\\Framework\\ObjectManagerInterface'), 'urlBuilder' => $this->_urlBuilder]); $this->_model = $this->getMock('Magento\\Theme\\Block\\Adminhtml\\System\\Design\\Theme\\Edit\\Tab\\Js', ['_getCurrentTheme'], $constructArguments, '', true); }
/** * @covers \Magento\Payment\Block\Form\Container::getChildBlock */ public function testSetMethodFormTemplate() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $childBlockA = $objectManagerHelper->getObject('Magento\\Framework\\View\\Element\\Template'); $childBlockB = $objectManagerHelper->getObject('Magento\\Framework\\View\\Element\\Template'); $func = function ($blockName) use($childBlockA, $childBlockB) { switch ($blockName) { case 'payment.method.a': return $childBlockA; case 'payment.method.b': return $childBlockB; } return null; }; $block = $this->getMock('Magento\\Payment\\Block\\Form\\Container', ['getChildBlock'], [], '', false); $block->expects($this->atLeastOnce())->method('getChildBlock')->will($this->returnCallback($func)); $template = 'any_template.phtml'; $this->assertNotEquals($template, $childBlockA->getTemplate()); $this->assertNotEquals($template, $childBlockB->getTemplate()); $block->setMethodFormTemplate('a', $template); $this->assertEquals($template, $childBlockA->getTemplate()); // Template is set to the block $this->assertNotEquals($template, $childBlockB->getTemplate()); // Template is not propagated to other blocks }
/** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function setUp() { $objectHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false); $coreData = $this->getMockBuilder('Magento\\Core\\Helper\\Data')->disableOriginalConstructor()->getMock(); $fileStorageDb = $this->getMockBuilder('Magento\\Core\\Helper\\File\\Storage\\Database')->disableOriginalConstructor()->getMock(); $filesystem = $this->getMockBuilder('Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock(); $coreRegistry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $productFactoryMock = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', [], [], '', false); $sampleResFactory = $this->getMock('Magento\\Downloadable\\Model\\Resource\\SampleFactory', [], [], '', false); $linkResource = $this->getMock('Magento\\Downloadable\\Model\\Resource\\Link', [], [], '', false); $linksFactory = $this->getMock('Magento\\Downloadable\\Model\\Resource\\Link\\CollectionFactory', [], [], '', false); $samplesFactory = $this->getMock('Magento\\Downloadable\\Model\\Resource\\Sample\\CollectionFactory', [], [], '', false); $sampleFactory = $this->getMock('Magento\\Downloadable\\Model\\SampleFactory', [], [], '', false); $linkFactory = $this->getMock('Magento\\Downloadable\\Model\\LinkFactory', [], [], '', false); $entityTypeMock = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false); $resourceProductMock = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product', ['getEntityType'], [], '', false); $resourceProductMock->expects($this->any())->method('getEntityType')->will($this->returnValue($entityTypeMock)); $this->product = $this->getMock('Magento\\Catalog\\Model\\Product', ['getResource', 'canAffectOptions', 'getLinksPurchasedSeparately', 'setTypeHasRequiredOptions', 'setRequiredOptions', 'getDownloadableData', 'setTypeHasOptions', 'setLinksExist', '__wakeup'], [], '', false); $this->product->expects($this->any())->method('getResource')->will($this->returnValue($resourceProductMock)); $this->product->expects($this->any())->method('setTypeHasRequiredOptions')->with($this->equalTo(true))->will($this->returnSelf()); $this->product->expects($this->any())->method('setRequiredOptions')->with($this->equalTo(true))->will($this->returnSelf()); $this->product->expects($this->any())->method('setTypeHasOptions')->with($this->equalTo(false)); $this->product->expects($this->any())->method('setLinksExist')->with($this->equalTo(false)); $this->product->expects($this->any())->method('canAffectOptions')->with($this->equalTo(true)); $this->product->expects($this->any())->method('getLinksPurchasedSeparately')->will($this->returnValue(true)); $this->product->expects($this->any())->method('getLinksPurchasedSeparately')->will($this->returnValue(true)); $eavConfigMock = $this->getMock('\\Magento\\Eav\\Model\\Config', ['getEntityAttributeCodes'], [], '', false); $eavConfigMock->expects($this->any())->method('getEntityAttributeCodes')->with($this->equalTo($entityTypeMock), $this->equalTo($this->product))->will($this->returnValue([])); $this->typeHandler = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Product\\TypeHandler\\TypeHandler')->disableOriginalConstructor()->setMethods(['save'])->getMock(); $this->target = $objectHelper->getObject('Magento\\Downloadable\\Model\\Product\\Type', ['eventManager' => $eventManager, 'coreData' => $coreData, 'fileStorageDb' => $fileStorageDb, 'filesystem' => $filesystem, 'coreRegistry' => $coreRegistry, 'logger' => $logger, 'productFactory' => $productFactoryMock, 'sampleResFactory' => $sampleResFactory, 'linkResource' => $linkResource, 'linksFactory' => $linksFactory, 'samplesFactory' => $samplesFactory, 'sampleFactory' => $sampleFactory, 'linkFactory' => $linkFactory, 'eavConfig' => $eavConfigMock, 'typeHandler' => $this->typeHandler]); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage stdClass doesn't implement ResolverInterface */ public function testCreateException() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); /** @var \Magento\Tools\I18n\Code\Dictionary\Options\ResolverFactory $resolverFactory */ $resolverFactory = $objectManagerHelper->getObject('Magento\\Tools\\I18n\\Code\\Dictionary\\Options\\ResolverFactory', ['resolverClass' => 'stdClass']); $resolverFactory->create('some_dir', true); }
public function testThatHandlerIsRight() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); /** @var \Magento\Tools\I18n\Dictionary\Writer\Csv $writer */ $writer = $objectManagerHelper->getObject('Magento\\Tools\\I18n\\Dictionary\\Writer\\Csv\\Stdo'); $this->assertAttributeEquals($this->_handler, '_fileHandler', $writer); }
protected function setUp() { $this->request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface'); $this->subject = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Element\\Field', [], [], '', false); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->model = $helper->getObject('Magento\\Paypal\\Model\\Config\\Structure\\Element\\FieldPlugin', ['request' => $this->request]); }
protected function setUp() { $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false, false); $arguments = ['urlBuilder' => $this->getMock('Magento\\Backend\\Model\\Url', [], [], '', false, false), 'layout' => $this->_layoutMock]; $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_blockMock = $objectManagerHelper->getObject('Magento\\Backend\\Block\\Widget\\Button', $arguments); }
protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_objectManager = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManager', array(), '', true, true, true, array('create')); $this->_expectedObject = $this->getMock('Magento\\Framework\\Acl\\Resource', array(), array(), '', false); $this->_model = $helper->getObject('Magento\\Framework\\Acl\\ResourceFactory', array('objectManager' => $this->_objectManager)); }
/** * Set up * * @return void */ protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->pageRepositoryMock = $this->getMock('Magento\\Cms\\Model\\PageRepository', [], [], '', false); $this->pageCriteriaFactoryMock = $this->getMock('Magento\\Cms\\Model\\Resource\\PageCriteriaFactory', ['create'], [], '', false); $this->page = $objectManager->getObject('Magento\\Cms\\Model\\Config\\Source\\Page', ['pageRepository' => $this->pageRepositoryMock, 'pageCriteriaFactory' => $this->pageCriteriaFactoryMock]); }
protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->addressMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', ['getShippingMethod', 'getShippingRateByCode', 'getAllVisibleItems', 'getTotals', 'getAddressType', '__wakeup'], [], '', false); $this->priceCurrencyMock = $this->getMock('Magento\\Framework\\Pricing\\PriceCurrencyInterface', [], [], '', false); $this->model = $objectManager->getObject('Magento\\Multishipping\\Block\\Checkout\\Overview', ['priceCurrency' => $this->priceCurrencyMock]); }
public function setUp() { $this->_storage = $this->getMockBuilder('Magento\\Widget\\Model\\Config\\Data')->disableOriginalConstructor()->getMock(); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $objectManagerHelper->getObject('Magento\\Widget\\Model\\Widget', array('dataStorage' => $this->_storage)); $this->_model = $objectManagerHelper->getObject('Magento\\Widget\\Model\\Widget', array('dataStorage' => $this->_storage)); }
protected function setUp() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $formKeyMock = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\FormKey')->setMethods(['getFormKey'])->disableOriginalConstructor()->getMock(); $formKeyMock->expects($this->any())->method('getFormKey')->will($this->returnValue('form_key')); $this->formKeyElement = $objectManagerHelper->getObject('Magento\\Framework\\View\\Element\\FormKey', ['formKey' => $formKeyMock]); }
protected function setUp() { $this->widget = $this->getMock('Magento\\Widget\\Model\\Widget\\Instance', [], [], '', false); $this->registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->propertiesBlock = $objectManager->getObject('Magento\\Widget\\Block\\Adminhtml\\Widget\\Instance\\Edit\\Tab\\Properties', ['registry' => $this->registry]); }
protected function setUp() { $objectHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $args = $objectHelper->getConstructArguments('Magento\\Paypal\\Model\\Pro', array('infoFactory' => $this->getMock('Magento\\Paypal\\Model\\InfoFactory'))); /** @var $pro \Magento\Paypal\Model\Pro */ $this->_pro = $this->getMock('Magento\\Paypal\\Model\\Pro', array('_isPaymentReviewRequired'), $args); }
/** * @return void */ protected function setUp() { $this->configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $this->eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface'); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->model = $objectManager->getObject('Magento\\Framework\\App\\Config\\Value', ['config' => $this->configMock, 'eventDispatcher' => $this->eventManager]); }
public function testAddFiltersVerifyAddConditionsToRegistry() { $registry = new \Magento\Framework\Registry(); $values = ['sku' => 'simple']; $this->resourceProvider->expects($this->once())->method('getResource')->willReturn($this->resource); $this->resourceProvider->expects($this->once())->method('getResourceCollection')->willReturn($this->collection); $this->resourceProvider->expects($this->once())->method('getAdvancedResultCollection')->willReturn($this->collection); $this->skuAttribute->expects($this->once())->method('getTable')->will($this->returnValue('catalog_product_entity')); $this->collection->expects($this->any())->method('addAttributeToSelect')->will($this->returnSelf()); $this->collection->expects($this->any())->method('setStore')->will($this->returnSelf()); $this->collection->expects($this->any())->method('addMinimalPrice')->will($this->returnSelf()); $this->collection->expects($this->any())->method('addTaxPercents')->will($this->returnSelf()); $this->collection->expects($this->any())->method('addStoreFilter')->will($this->returnSelf()); $this->collection->expects($this->any())->method('setVisibility')->will($this->returnSelf()); $this->resource->expects($this->any())->method('prepareCondition')->will($this->returnValue(['like' => '%simple%'])); $this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('entity_id')); $this->attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue('sku')); $this->attribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue('SKU')); $this->attribute->expects($this->any())->method('getFrontendInput')->will($this->returnValue('text')); $this->attribute->expects($this->any())->method('getBackend')->will($this->returnValue($this->skuAttribute)); $this->attribute->expects($this->any())->method('getBackendType')->will($this->returnValue('static')); $this->dataCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->attribute]))); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); /** @var \Magento\CatalogSearch\Model\Advanced $instance */ $instance = $objectManager->getObject('Magento\\CatalogSearch\\Model\\Advanced', ['registry' => $registry, 'resourceProvider' => $this->resourceProvider, 'data' => ['attributes' => $this->dataCollection]]); $instance->addFilters($values); $this->assertNotNull($registry->registry('advanced_search_conditions')); }
protected function setUp() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_collectionMock = $this->getMock('Magento\\Directory\\Model\\Resource\\Country\\Collection', [], [], '', false); $arguments = ['countryCollection' => $this->_collectionMock]; $this->_model = $objectManagerHelper->getObject('Magento\\Directory\\Model\\Config\\Source\\Country', $arguments); }
protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->priceCurrency = $this->getMockBuilder('Magento\\Framework\\Pricing\\PriceCurrencyInterface')->getMock(); $this->taxHelper = $this->getMockBuilder('\\Magento\\Tax\\Helper\\Data')->disableOriginalConstructor()->setMethods(['displayCartPriceExclTax', 'displayCartBothPrices', 'displayCartPriceInclTax', 'displaySalesPriceExclTax', 'displaySalesBothPrices', 'displaySalesPriceInclTax'])->getMock(); $this->renderer = $objectManager->getObject('\\Magento\\Tax\\Block\\Item\\Price\\Renderer', ['taxHelper' => $this->taxHelper, 'priceCurrency' => $this->priceCurrency, 'data' => ['zone' => Render::ZONE_CART]]); }
protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteRepositoryMock = $this->getMock('\\Magento\\Sales\\Model\\QuoteRepository', [], [], '', false); $this->couponBuilderMock = $this->getMock('\\Magento\\Checkout\\Service\\V1\\Data\\Cart\\CouponBuilder', [], [], '', false); $this->service = $objectManager->getObject('\\Magento\\Checkout\\Service\\V1\\Coupon\\ReadService', ['quoteRepository' => $this->quoteRepositoryMock, 'couponBuilder' => $this->couponBuilderMock]); }
/** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function setUp() { $this->_helper = new \Magento\TestFramework\Helper\ObjectManager($this); $scopeConfig = $this->getMockBuilder('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')->setMethods(array('isSetFlag', 'getValue'))->disableOriginalConstructor()->getMock(); $scopeConfig->expects($this->any())->method('isSetFlag')->will($this->returnValue(true)); $scopeConfig->expects($this->any())->method('getValue')->will($this->returnCallback(array($this, 'scopeConfiggetValue'))); // xml element factory $xmlElFactory = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Simplexml\\ElementFactory')->disableOriginalConstructor()->setMethods(array('create'))->getMock(); $xmlElFactory->expects($this->any())->method('create')->will($this->returnCallback(function ($data) { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); return $helper->getObject('\\Magento\\Shipping\\Model\\Simplexml\\Element', array('data' => $data['data'])); })); // rate factory $rateFactory = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Rate\\ResultFactory')->disableOriginalConstructor()->setMethods(array('create'))->getMock(); $rateResult = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Rate\\Result')->disableOriginalConstructor()->setMethods(null)->getMock(); $rateFactory->expects($this->any())->method('create')->will($this->returnValue($rateResult)); // rate method factory $rateMethodFactory = $this->getMockBuilder('\\Magento\\Sales\\Model\\Quote\\Address\\RateResult\\MethodFactory')->disableOriginalConstructor()->setMethods(array('create'))->getMock(); $rateMethod = $this->getMockBuilder('Magento\\Sales\\Model\\Quote\\Address\\RateResult\\Method')->disableOriginalConstructor()->setMethods(array('setPrice'))->getMock(); $rateMethod->expects($this->any())->method('setPrice')->will($this->returnSelf()); $rateMethodFactory->expects($this->any())->method('create')->will($this->returnValue($rateMethod)); // http client $this->_httpResponse = $this->getMockBuilder('\\Zend_Http_Response')->disableOriginalConstructor()->setMethods(array('getBody'))->getMock(); $httpClient = $this->getMockBuilder('\\Magento\\Framework\\HTTP\\ZendClient')->disableOriginalConstructor()->setMethods(array('request'))->getMock(); $httpClient->expects($this->any())->method('request')->will($this->returnValue($this->_httpResponse)); $httpClientFactory = $this->getMockBuilder('\\Magento\\Framework\\HTTP\\ZendClientFactory')->disableOriginalConstructor()->setMethods(array('create'))->getMock(); $httpClientFactory->expects($this->any())->method('create')->will($this->returnValue($httpClient)); $data = array('id' => 'usps', 'store' => '1'); $arguments = array('scopeConfig' => $scopeConfig, 'xmlElFactory' => $xmlElFactory, 'rateFactory' => $rateFactory, 'rateMethodFactory' => $rateMethodFactory, 'httpClientFactory' => $httpClientFactory, 'data' => $data); $this->_model = $this->_helper->getObject('Magento\\Usps\\Model\\Carrier', $arguments); }
protected function setUp() { // dev/tests/unit/testsuite/tools/I18n/Parser/Adapter/_files/layout.xml $this->_testFile = str_replace('\\', '/', realpath(dirname(__FILE__))) . '/_files/default.xml'; $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_adapter = $objectManagerHelper->getObject('Magento\\Tools\\I18n\\Code\\Parser\\Adapter\\Xml'); }
protected function setUp() { $this->_registry = $this->getMock('Magento\\Framework\\Registry', array(), array(), '', false); $this->_agreementResource = $this->getMock('\\Magento\\Paypal\\Model\\Resource\\Billing\\Agreement', array(), array(), '', false); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $helper->getObject('Magento\\Paypal\\Model\\Billing\\Agreement\\OrdersUpdater', array('coreRegistry' => $this->_registry, 'agreementResource' => $this->_agreementResource)); }
protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->validator = $this->getMockBuilder('Magento\\SalesRule\\Model\\Validator')->disableOriginalConstructor()->setMethods(['getItemPrice', 'getItemBasePrice', 'getItemOriginalPrice', 'getItemBaseOriginalPrice', '__wakeup'])->getMock(); $this->discountDataFactory = $this->getMockBuilder('Magento\\SalesRule\\Model\\Rule\\Action\\Discount\\DataFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->model = $helper->getObject('Magento\\SalesRule\\Model\\Rule\\Action\\Discount\\ToPercent', ['discountDataFactory' => $this->discountDataFactory, 'validator' => $this->validator]); }
protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->messageMock = $this->getMock('\\Magento\\GiftMessage\\Model\\GiftMessageManager', [], [], '', false); $this->requestMock = $this->getMock('\\Magento\\Framework\\App\\RequestInterface'); $this->plugin = $objectManager->getObject('Magento\\GiftMessage\\Model\\Type\\Plugin\\Onepage', ['message' => $this->messageMock, 'request' => $this->requestMock]); }
protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->rowMock = $this->getMock('Magento\\Framework\\Object', array('getTypeId', 'getIndex'), array(), '', false); $this->typeConfigMock = $this->getMock('Magento\\Catalog\\Model\\ProductTypes\\ConfigInterface'); $this->renderer = $helper->getObject('Magento\\Sales\\Block\\Adminhtml\\Order\\Create\\Search\\Grid\\Renderer\\Qty', array('typeConfig' => $this->typeConfigMock)); }
public function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->eavConfig = $this->getMock('Magento\\Eav\\Model\\Config', ['getEntityType'], [], '', false); $this->model = $objectManager->getObject('Magento\\Sales\\Model\\Increment', ['eavConfig' => $this->eavConfig]); $this->type = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', ['fetchNewIncrementId'], [], '', false); }
protected function setUp() { $this->coreHelper = $this->getMock('Magento\\Core\\Helper\\Data', ['jsonEncode'], [], '', false); $this->mathRandom = $this->getMock('Magento\\Framework\\Math\\Random', [], [], '', false); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->object = $objectManager->getObject('Magento\\Catalog\\Pricing\\Render\\PriceBox', ['coreDataHelper' => $this->coreHelper, 'mathRandom' => $this->mathRandom]); }
public function testGoBack() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $storeManagerMock = $this->getMock('Magento\\Framework\\StoreManagerInterface'); $responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', array(), array(), '', false); $responseMock->headersSentThrowsException = false; $requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', array(), array(), '', false); $requestMock->expects($this->any())->method('getActionName')->will($this->returnValue('add')); $requestMock->expects($this->at(0))->method('getParam')->with('return_url')->will($this->returnValue('http://malicious.com/')); $requestMock->expects($this->any())->method('getParam')->will($this->returnValue(null)); $redirect = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface'); $redirect->expects($this->any())->method('getRefererUrl')->will($this->returnValue('http://some-url/index.php/product.html')); $checkoutSessionMock = $this->getMock('Magento\\Checkout\\Model\\Session', array('setContinueShoppingUrl'), array(), '', false); $checkoutSessionMock->expects($this->once())->method('setContinueShoppingUrl')->with('http://some-url/index.php/product.html')->will($this->returnSelf()); $redirect->expects($this->once())->method('redirect')->will($this->returnValue('http://some-url/index.php/checkout/cart/')); $storeMock = $this->getMock('Magento\\Store\\Model\\Store', array(), array(), '', false); $storeMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue('http://some-url/')); $configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $configMock->expects($this->once())->method('getValue')->with('checkout/cart/redirect_to_cart')->will($this->returnValue('1')); $storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); $arguments = array('response' => $responseMock, 'request' => $requestMock, 'checkoutSession' => $checkoutSessionMock, 'scopeConfig' => $configMock, 'redirect' => $redirect, 'storeManager' => $storeManagerMock); $controller = $helper->getObject('Magento\\Checkout\\Controller\\Cart', $arguments); $reflectionObject = new \ReflectionObject($controller); $reflectionMethod = $reflectionObject->getMethod('_goBack'); $reflectionMethod->setAccessible(true); $reflectionMethod->invoke($controller); }
public function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $objectFactory = new \Magento\Webapi\Service\Entity\WebapiObjectManager($objectManager); $typeProcessor = $objectManager->getObject('Magento\\Webapi\\Model\\Config\\ClassReflector\\TypeProcessor'); $this->serializer = $objectManager->getObject('Magento\\Webapi\\Controller\\ServiceArgsSerializer', ['typeProcessor' => $typeProcessor, 'objectManager' => $objectFactory]); }
protected function setUp() { $this->collectionFactory = $this->getMockBuilder('Magento\\Framework\\Message\\CollectionFactory')->disableOriginalConstructor()->getMock(); $this->messageFactory = $this->getMockBuilder('Magento\\Framework\\Message\\Factory')->disableOriginalConstructor()->getMock(); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->messages = $objectManager->getObject('Magento\\Framework\\View\\Element\\Messages', ['collectionFactory' => $this->collectionFactory, 'messageFactory' => $this->messageFactory]); }