protected function setUp() { $this->select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->setMethods(['from', 'joinLeft', 'where', 'joinInner'])->getMock(); $this->adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->setMethods(['select', 'quoteInto'])->getMockForAbstractClass(); $this->adapter->expects($this->once())->method('select')->will($this->returnValue($this->select)); $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->setMethods(['getConnection', 'getTableName'])->getMock(); $this->resource->expects($this->any())->method('getConnection')->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE)->will($this->returnValue($this->adapter)); $this->request = $this->getMockBuilder('\\Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->setMethods(['getIndex', 'getDimensions', 'getQuery'])->getMockForAbstractClass(); $this->request->expects($this->once())->method('getQuery')->willReturn($this->getMockBuilder('Magento\\Framework\\Search\\Request\\QueryInterface')->getMockForAbstractClass()); $this->config = $this->getMockBuilder('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')->disableOriginalConstructor()->setMethods(['isSetFlag'])->getMockForAbstractClass(); $this->storeManager = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->getMock(); $this->scopeResolver = $this->getMockBuilder('\\Magento\\Indexer\\Model\\ScopeResolver\\IndexScopeResolver')->disableOriginalConstructor()->getMock(); $this->conditionManager = $this->getMockBuilder('\\Magento\\Framework\\Search\\Adapter\\Mysql\\ConditionManager')->setMethods(['combineQueries', 'wrapBrackets', 'generateCondition'])->disableOriginalConstructor()->getMock(); $this->conditionManager->expects($this->any())->method('combineQueries')->willReturnCallback(function (array $queries, $expression) { return implode(' ' . $expression . ' ', $queries); }); $this->conditionManager->expects($this->any())->method('wrapBrackets')->willReturnCallback(function ($expression) { return '(' . $expression . ')'; }); $this->conditionManager->expects($this->any())->method('generateCondition')->willReturnCallback(function ($left, $operator, $right) { return $left . $operator . $right; }); $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject('Magento\\CatalogSearch\\Model\\Search\\IndexBuilder', ['resource' => $this->resource, 'config' => $this->config, 'storeManager' => $this->storeManager, 'conditionManager' => $this->conditionManager, 'scopeResolver' => $this->scopeResolver]); }
protected function setUp() { $objectManager = new ObjectManager($this); $this->metadata = $this->getMock('Magento\\Sales\\Model\\ResourceModel\\Metadata', ['getNewInstance', 'getMapper'], [], '', false); $this->searchResultFactory = $this->getMock('Magento\\Sales\\Api\\Data\\ShipmentSearchResultInterfaceFactory', ['create'], [], '', false); $this->subject = $objectManager->getObject('Magento\\Sales\\Model\\Order\\ShipmentRepository', ['metadata' => $this->metadata, 'searchResultFactory' => $this->searchResultFactory]); }
protected function setUp() { $this->scopeConfigMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $this->requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->designExceptions = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\DesignExceptions', ['scopeConfig' => $this->scopeConfigMock, 'exceptionConfigPath' => $this->exceptionConfigPath, 'scopeType' => $this->scopeType]); }
/** * Run test getDataSourceData method * * @return void * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testGetDataSourceData() { $result = [['type' => 'test_component_name', 'name' => 'test_name', 'dataScope' => 'test_namespace', 'config' => ['data' => ['items' => ['data']], 'totalCount' => 20, 'testConfig' => 'testConfigValue', 'params' => ['namespace' => 'test_namespace']]]]; /** @var DataSourceInterface|\PHPUnit_Framework_MockObject_MockObject $dataSourceMock */ $dataSourceMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataSourceInterface', [], '', false); /** @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */ $dataProviderMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false); /** @var Columns|\PHPUnit_Framework_MockObject_MockObject $columnsMock */ $columnsMock = $this->getMock('Magento\\Ui\\Component\\Listing\\Columns', [], [], '', false); /** @var Column|\PHPUnit_Framework_MockObject_MockObject $columnMock */ $columnMock = $this->getMock('Magento\\Ui\\Component\\Listing\\Columns\\Column', [], [], '', false); /** @var Listing $listing */ $listing = $this->objectManager->getObject('Magento\\Ui\\Component\\Listing', ['context' => $this->contextMock, 'components' => [$dataSourceMock, $columnsMock], 'data' => ['js_config' => ['extends' => 'test_config_extends', 'testData' => 'testValue']]]); $columnsMock->expects($this->once())->method('getChildComponents')->willReturn([$columnMock]); $dataSourceMock->expects($this->any())->method('getDataProvider')->willReturn($dataProviderMock); $dataProviderMock->expects($this->once())->method('getData')->willReturn(['items' => ['data']]); $columnMock->expects($this->once())->method('prepareItems')->with(['data']); $dataSourceMock->expects($this->once())->method('getComponentName')->willReturn('test_component_name'); $dataSourceMock->expects($this->once())->method('getName')->willReturn('test_name'); $dataSourceMock->expects($this->once())->method('getContext')->willReturn($this->contextMock); $this->contextMock->expects($this->any())->method('getNamespace')->willReturn('test_namespace'); $dataProviderMock->expects($this->once())->method('count')->willReturn(20); $dataSourceMock->expects($this->once())->method('getData')->with('config')->willReturn(['testConfig' => 'testConfigValue']); $this->assertEquals($listing->getDataSourceData(), $result); }
protected function setUp() { $objectManager = new ObjectManager($this); $this->taxRuleModelFactoryMock = $this->getMockBuilder('Magento\\Tax\\Model\\Calculation\\RuleFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock(); $this->taxRuleRegistry = $objectManager->getObject('Magento\\Tax\\Model\\Calculation\\TaxRuleRegistry', ['taxRuleModelFactory' => $this->taxRuleModelFactoryMock]); $this->taxRuleModelMock = $this->getMockBuilder('Magento\\Tax\\Model\\Calculation\\Rule')->disableOriginalConstructor()->getMock(); }
protected function setUp() { $objectManager = new ObjectManager($this); $this->setFactoryMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\SetFactory', ['create', '__wakeup'], [], '', false); $this->typeFactoryMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\TypeFactory', ['create', '__wakeup'], [], '', false); $this->model = $objectManager->getObject('Magento\\Catalog\\Model\\ResourceModel\\Product', ['setFactory' => $this->setFactoryMock, 'typeFactory' => $this->typeFactoryMock]); }
/** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $connection = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', ['quote'], [], '', false); $connection->expects($this->any())->method('quote')->will($this->returnValue('\'TestProductName\'')); $resource = $this->getMock('Magento\\Wishlist\\Model\\Resource\\Item', ['getReadConnection', 'getMainTable', 'getTableName', 'getTable'], [], '', false); $resource->expects($this->any())->method('getReadConnection')->will($this->returnValue($connection)); $resource->expects($this->any())->method('getMainTable')->will($this->returnValue('testMainTableName')); $resource->expects($this->any())->method('getTableName')->will($this->returnValue('testMainTableName')); $resource->expects($this->any())->method('getTable')->will($this->returnValue('testMainTableName')); $catalogConfFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\ConfigFactory', ['create'], [], '', false); $catalogConf = $this->getMock('Magento\\Catalog\\Model\\Resource\\Config', ['getEntityTypeId'], [], '', false); $catalogConf->expects($this->once())->method('getEntityTypeId')->will($this->returnValue(4)); $catalogConfFactory->expects($this->once())->method('create')->will($this->returnValue($catalogConf)); $attribute = $this->getMock('Magento\\Catalog\\Model\\Entity\\Attribute', ['loadByCode', 'getBackendTable', 'getId'], [], '', false); $attribute->expects($this->once())->method('loadByCode')->with(4, 'name')->will($this->returnSelf()); $attribute->expects($this->once())->method('getBackendTable')->will($this->returnValue($this->attrTableName)); $attribute->expects($this->once())->method('getId')->will($this->returnValue($this->attrId)); $catalogAttrFactory = $this->getMock('Magento\\Catalog\\Model\\Entity\\AttributeFactory', ['create'], [], '', false); $catalogAttrFactory->expects($this->once())->method('create')->will($this->returnValue($attribute)); $store = $this->getMock('Magento\\Store\\Model\\Store', ['getId'], [], '', false); $store->expects($this->once())->method('getId')->will($this->returnValue($this->storeId)); $storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', ['getStore'], [], '', false); $storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store)); $this->collection = $this->objectManager->getObject('Magento\\Wishlist\\Model\\Resource\\Item\\Collection', ['resource' => $resource, 'catalogConfFactory' => $catalogConfFactory, 'catalogAttrFactory' => $catalogAttrFactory, 'storeManager' => $storeManager]); }
/** * Set up helper. */ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $typeProcessor = $this->objectManager->getObject('Magento\\Framework\\Reflection\\TypeProcessor'); $objectManagerMock = $this->getMockBuilder('Magento\\Framework\\App\\ObjectManager')->disableOriginalConstructor()->getMock(); $classReflection = $this->getMock('Magento\\Webapi\\Model\\Config\\ClassReflector', ['reflectClassMethods'], ['_typeProcessor' => $typeProcessor], ''); $classReflection->expects($this->any())->method('reflectClassMethods')->will($this->returnValue([])); $servicesConfig = ['services' => ['Magento\\Customer\\Api\\AccountManagementInterface' => ['V1' => ['methods' => ['activate' => ['resources' => [['Magento_Customer::manage']], 'secure' => false]]]], 'Magento\\Customer\\Api\\CustomerRepositoryInterface' => ['V1' => ['methods' => ['getById' => ['resources' => [['Magento_Customer::customer']], 'secure' => false]]]]]]; /** * @var $registryMock \Magento\Framework\Registry */ $registryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->disableOriginalConstructor()->getMock(); /** * @var $cacheMock \Magento\Framework\App\Cache\Type\Webapi */ $cacheMock = $this->getMockBuilder('Magento\\Framework\\App\\Cache\\Type\\Webapi')->disableOriginalConstructor()->getMock(); /** @var $readerMock \Magento\Webapi\Model\Config\Reader */ $readerMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Config\\Reader')->disableOriginalConstructor()->getMock(); $readerMock->expects($this->any())->method('read')->will($this->returnValue($servicesConfig)); /** @var $config \Magento\Webapi\Model\Config */ $config = new \Magento\Webapi\Model\Config($cacheMock, $readerMock); /** @var $config \Magento\Webapi\Model\ServiceMetadata */ $serviceMetadata = new \Magento\Webapi\Model\ServiceMetadata($config, $cacheMock, $classReflection, $typeProcessor); $this->_soapConfig = $this->objectManager->getObject('Magento\\Webapi\\Model\\Soap\\Config', ['objectManager' => $objectManagerMock, 'registry' => $registryMock, 'serviceMetadata' => $serviceMetadata]); parent::setUp(); }
public function setUp() { $this->orderFactory = $this->getMock('\\Magento\\Sales\\Model\\OrderFactory', ['create'], [], '', false); $objectManagerHelper = new ObjectManagerHelper($this); $arguments = ['context' => $this->getMock('Magento\\Framework\\Model\\Context', [], [], '', false), 'registry' => $this->getMock('Magento\\Framework\\Registry', [], [], '', false), 'localeDate' => $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface', [], [], '', false), 'dateTime' => $this->getMock('Magento\\Framework\\Stdlib\\DateTime', [], [], '', false), 'orderFactory' => $this->orderFactory, 'shipmentItemCollectionFactory' => $this->getMock('Magento\\Sales\\Model\\Resource\\Order\\Shipment\\Item\\CollectionFactory', [], [], '', false), 'trackCollectionFactory' => $this->getMock('Magento\\Sales\\Model\\Resource\\Order\\Shipment\\Track\\CollectionFactory', [], [], '', false), 'commentFactory' => $this->getMock('Magento\\Sales\\Model\\Order\\Shipment\\CommentFactory', [], [], '', false), 'commentCollectionFactory' => $this->getMock('Magento\\Sales\\Model\\Resource\\Order\\Shipment\\Comment\\CollectionFactory', [], [], '', false)]; $this->shipment = $objectManagerHelper->getObject('Magento\\Sales\\Model\\Order\\Shipment', $arguments); }
protected function setUp() { $this->entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', [], [], '', false); $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface'); $this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface'); $this->managerInterfaceMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface'); $this->configMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false); $this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false); $this->entityFactoryMock2 = $this->getMock('Magento\\Eav\\Model\\EntityFactory', [], [], '', false); $this->helperMock = $this->getMock('Magento\\Catalog\\Model\\Resource\\Helper', [], [], '', false); $entity = $this->getMock('Magento\\Eav\\Model\\Entity\\AbstractEntity', [], [], '', false); $adapter = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', [], '', false); $entity->expects($this->any())->method('getReadConnection')->will($this->returnValue($adapter)); $entity->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([])); $this->universalFactoryMock = $this->getMock('Magento\\Framework\\Validator\\UniversalFactory', [], [], '', false); $this->universalFactoryMock->expects($this->any())->method('create')->will($this->returnValue($entity)); $this->storeManagerMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface'); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnCallback(function ($store) { return is_object($store) ? $store : new \Magento\Framework\Object(['id' => 42]); })); $this->catalogHelperMock = $this->getMock('Magento\\Catalog\\Helper\\Data', [], [], '', false); $this->stateMock = $this->getMock('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\State', [], [], '', false); $this->scopeConfigInterfaceMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $this->optionFactoryMock = $this->getMock('Magento\\Catalog\\Model\\Product\\OptionFactory', [], [], '', false); $this->urlMock = $this->getMock('Magento\\Catalog\\Model\\Resource\\Url', [], [], '', false); $this->timezoneInterfaceMock = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface'); $this->sessionMock = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false); $this->dateTimeMock = $this->getMock('Magento\\Framework\\Stdlib\\DateTime'); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->collection = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Resource\\Product\\Link\\Product\\Collection', ['entityFactory' => $this->entityFactoryMock, 'logger' => $this->loggerMock, 'fetchStrategy' => $this->fetchStrategyMock, 'eventManager' => $this->managerInterfaceMock, 'eavConfig' => $this->configMock, 'resource' => $this->resourceMock, 'eavEntityFactory' => $this->entityFactoryMock2, 'resourceHelper' => $this->helperMock, 'universalFactory' => $this->universalFactoryMock, 'storeManager' => $this->storeManagerMock, 'catalogData' => $this->catalogHelperMock, 'catalogProductFlatState' => $this->stateMock, 'scopeConfig' => $this->scopeConfigInterfaceMock, 'productOptionFactory' => $this->optionFactoryMock, 'catalogUrl' => $this->urlMock, 'localeDate' => $this->timezoneInterfaceMock, 'customerSession' => $this->sessionMock, 'dateTime' => $this->dateTimeMock]); }
protected function setUp() { $this->paypalMethodMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\PaymentMethod\\PayPal')->disableOriginalConstructor()->getMock(); $this->paypalConfigMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\Config\\PayPal')->disableOriginalConstructor()->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->addPaypalShortcutsObserver = $this->objectManagerHelper->getObject('Magento\\Braintree\\Observer\\AddPaypalShortcuts', ['methodPayPal' => $this->paypalMethodMock, 'paypalConfig' => $this->paypalConfigMock]); }
protected function setUp() { $objectManager = new ObjectManager($this); $this->_storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false); $this->_authorizationMock = $this->getMock('Magento\\Framework\\AuthorizationInterface'); $this->_model = $objectManager->getObject('Magento\\Config\\Model\\Config\\Structure\\Element\\Section', ['storeManager' => $this->_storeManagerMock, 'authorization' => $this->_authorizationMock]); }
public function setUp() { parent::setUp(); $objectManager = new ObjectManager($this); $this->entitySnapshot = $this->getMock('Magento\\Framework\\Model\\ResourceModel\\Db\\VersionControl\\Snapshot', ['registerSnapshot'], [], '', false); $this->subject = $objectManager->getObject('Magento\\Eav\\Test\\Unit\\Model\\Entity\\Collection\\VersionControl\\AbstractCollectionStub', ['entityFactory' => $this->coreEntityFactoryMock, 'universalFactory' => $this->validatorFactoryMock, 'entitySnapshot' => $this->entitySnapshot]); }
protected function setUp() { $objectManager = new ObjectManager($this); $this->connection = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMock(); $this->connection->expects($this->any())->method('quoteInto')->willReturnCallback(function ($query, $expression) { return str_replace('?', $expression, $query); }); $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\ResourceConnection')->disableOriginalConstructor()->getMock(); $this->resource->method('getTableName')->willReturnCallback(function ($table) { return 'prefix_' . $table; }); $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection); $this->website = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\WebsiteInterface')->disableOriginalConstructor()->getMockForAbstractClass(); $this->website->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID); $this->store = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->getMockForAbstractClass(); $this->store->expects($this->any())->method('getId')->willReturn(self::STORE_ID); $this->storeManager = $this->getMockBuilder('\\Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock(); $this->storeManager->expects($this->any())->method('getWebsite')->willReturn($this->website); $this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store); $this->attributeCollection = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection')->disableOriginalConstructor()->getMock(); $attributeCollectionFactory = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock(); $attributeCollectionFactory->expects($this->once())->method('create')->willReturn($this->attributeCollection); $this->target = $objectManager->getObject('\\Magento\\CatalogSearch\\Model\\Search\\TableMapper', ['resource' => $this->resource, 'storeManager' => $this->storeManager, 'attributeCollectionFactory' => $attributeCollectionFactory]); $this->select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock(); $this->request = $this->getMockBuilder('\\Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->getMock(); }
public function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_indexerMock = $this->getMock('Magento\\Indexer\\Model\\Indexer', ['getId', 'invalidate', 'getPriceIndexer', 'isScheduled'], [], '', false); $this->indexerRegistryMock = $this->getMock('Magento\\Framework\\Indexer\\IndexerRegistry', ['get'], [], '', false); $this->_model = $this->_objectManager->getObject('Magento\\CatalogImportExport\\Model\\Indexer\\Product\\Price\\Plugin\\Import', ['indexerRegistry' => $this->indexerRegistryMock]); }
public function setUp() { $this->dependencyFirst = $this->getMock('Magento\\Setup\\Module\\Dependency\\Report\\Dependency\\Data\\Dependency', [], [], '', false); $this->dependencySecond = $this->getMock('Magento\\Setup\\Module\\Dependency\\Report\\Dependency\\Data\\Dependency', [], [], '', false); $objectManagerHelper = new ObjectManager($this); $this->module = $objectManagerHelper->getObject('Magento\\Setup\\Module\\Dependency\\Report\\Dependency\\Data\\Module', ['name' => 'name', 'dependencies' => [$this->dependencyFirst, $this->dependencySecond]]); }
public function setUp() { $this->customerFactory = $this->getMockBuilder('Magento\\Customer\\Model\\CustomerFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock(); $objectManager = new ObjectManager($this); $this->customerRegistry = $objectManager->getObject('Magento\\Customer\\Model\\CustomerRegistry', ['customerFactory' => $this->customerFactory]); $this->customer = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->disableOriginalConstructor()->setMethods(['load', 'getId', 'getEmail', 'getWebsiteId', '__wakeup', 'setEmail', 'setWebsiteId', 'loadByEmail'])->getMock(); }
protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->filePath = __DIR__ . '/_files/'; $this->source = new \DOMDocument(); $this->model = $this->objectManagerHelper->getObject(Converter::class); }
protected function setUp() { $this->helper = new ObjectManager($this); $this->scopeConfig = $this->getMockBuilder('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')->disableOriginalConstructor()->getMock(); $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface'); $this->adapterFactory = $this->helper->getObject('\\Magento\\Search\\Model\\AdapterFactory', ['objectManager' => $this->objectManager, 'scopeConfig' => $this->scopeConfig, 'path' => 'some_path', 'scopeType' => 'some_scopeType', 'adapters' => ['ClassName' => 'ClassName']]); }
protected function setUp() { $this->configMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\Config\\PayPal')->disableOriginalConstructor()->getMock(); $this->localResolverMock = $this->getMock('\\Magento\\Framework\\Locale\\ResolverInterface'); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject('Magento\\Braintree\\Model\\ConfigProvider\\PayPal', ['config' => $this->configMock, 'localeResolver' => $this->localResolverMock]); }
protected function setUp() { $this->urlInterface = $this->getMock('Magento\\Framework\\UrlInterface'); $this->scopeConfigInterface = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $objectManagerHelper = new ObjectManagerHelper($this); $this->urlBuilder = $objectManagerHelper->getObject('Magento\\Rss\\Model\\UrlBuilder', ['urlBuilder' => $this->urlInterface, 'scopeConfig' => $this->scopeConfigInterface]); }
public function setUp() { $objectManagerHelper = new ObjectManager($this); $this->dataValidator = $this->getMockBuilder(Refund\DataValidator::class)->getMock(); $this->methodCaller = $this->getMockBuilder(MethodCaller::class)->disableOriginalConstructor()->getMock(); $this->model = $objectManagerHelper->getObject(Refund::class, ['dataValidator' => $this->dataValidator, 'methodCaller' => $this->methodCaller]); }
/** * Set up */ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->rowCustomizerMock = $this->objectManagerHelper->getObject('\\Magento\\BundleImportExport\\Model\\Export\\RowCustomizer'); $this->productResourceCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', ['addAttributeToFilter', 'getIterator'], [], '', false); $this->product = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getId', 'getPriceType', 'getSkuType', 'getPriceView', 'getWeightType', 'getTypeInstance', 'getOptionsCollection', 'getSelectionsCollection'], [], '', false); $this->product->expects($this->any())->method('getId')->willReturn(1); $this->product->expects($this->any())->method('getPriceType')->willReturn(1); $this->product->expects($this->any())->method('getSkuType')->willReturn(1); $this->product->expects($this->any())->method('getPriceView')->willReturn(1); $this->product->expects($this->any())->method('getWeightType')->willReturn(1); $this->product->expects($this->any())->method('getTypeInstance')->willReturnSelf(); $this->optionsCollection = $this->getMock('\\Magento\\Bundle\\Model\\ResourceModel\\Option\\Collection', ['setOrder', 'getIterator'], [], '', false); $this->product->expects($this->any())->method('getOptionsCollection')->willReturn($this->optionsCollection); $this->optionsCollection->expects($this->any())->method('setOrder')->willReturnSelf(); $this->option = $this->getMock('\\Magento\\Bundle\\Model\\Option', ['getId', 'getTitle', 'getType', 'getRequired'], [], '', false); $this->option->expects($this->any())->method('getId')->willReturn(1); $this->option->expects($this->any())->method('getTitle')->willReturn('title'); $this->option->expects($this->any())->method('getType')->willReturn(1); $this->option->expects($this->any())->method('getRequired')->willReturn(1); $this->optionsCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->option]))); $this->selection = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getSku', 'getSelectionPriceValue', 'getIsDefault', 'getSelectionQty', 'getSelectionPriceType'], [], '', false); $this->selection->expects($this->any())->method('getSku')->willReturn(1); $this->selection->expects($this->any())->method('getSelectionPriceValue')->willReturn(1); $this->selection->expects($this->any())->method('getSelectionQty')->willReturn(1); $this->selection->expects($this->any())->method('getSelectionPriceType')->willReturn(1); $this->selectionsCollection = $this->getMock('\\Magento\\Bundle\\Model\\ResourceModel\\Selection\\Collection', ['getIterator', 'addAttributeToSort'], [], '', false); $this->selectionsCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->selection]))); $this->selectionsCollection->expects($this->any())->method('addAttributeToSort')->willReturnSelf(); $this->product->expects($this->any())->method('getSelectionsCollection')->willReturn($this->selectionsCollection); $this->productResourceCollection->expects($this->any())->method('addAttributeToFilter')->willReturnSelf(); $this->productResourceCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->product]))); }
protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->mockCmsPage = $this->getMock('Magento\\Cms\\Helper\\Page', [], [], '', false, false); $this->mockResourcePage = $this->getMock('Magento\\Cms\\Model\\ResourceModel\\Page', [], [], '', false, false); $this->linkElement = $this->objectManager->getObject('Magento\\Cms\\Block\\Widget\\Page\\Link', ['cmsPage' => $this->mockCmsPage, 'resourcePage' => $this->mockResourcePage]); }
/** * Tests the methods that rely on the ScopeConfigInterface object to provide their return values * * @param array $initialArray The initial array that specifies the set of additional options * @param bool $weeeEnabled Whether the Weee module is assumed to be enabled * @param int $weeeDisplay Which Weee display is configured * @param int $priceDisplay Values are: including tax, excluding tax, or both including and excluding tax * @param array $expectedArray The revised array of the additional options * * @dataProvider updateProductOptionsProvider */ public function testUpdateProductOptions($initialArray, $weeeEnabled, $weeeDisplay, $priceDisplay, $expectedArray) { $configObj = new \Magento\Framework\DataObject(['additional_options' => $initialArray]); $weeeObject1 = new \Magento\Framework\DataObject(['code' => 'fpt1', 'amount' => '15.0000']); $weeeObject2 = new \Magento\Framework\DataObject(['code' => 'fpt2', 'amount' => '7.0000']); $weeeHelper = $this->getMock('Magento\\Weee\\Helper\\Data', [], [], '', false); $weeeHelper->expects($this->any())->method('isEnabled')->will($this->returnValue($weeeEnabled)); $weeeHelper->expects($this->any())->method('isDisplayIncl')->will($this->returnValue($weeeDisplay == WeeeDisplayConfig::DISPLAY_INCL)); $weeeHelper->expects($this->any())->method('isDisplayExclDescIncl')->will($this->returnValue($weeeDisplay == WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL)); $weeeHelper->expects($this->any())->method('isDisplayExcl')->will($this->returnValue($weeeDisplay == WeeeDisplayConfig::DISPLAY_EXCL)); $weeeHelper->expects($this->any())->method('getWeeeAttributesForBundle')->will($this->returnValue([['fpt1' => $weeeObject1], ['fpt1' => $weeeObject1, 'fpt2' => $weeeObject2]])); $taxHelper = $this->getMock('Magento\\Tax\\Helper\\Data', [], [], '', false); $taxHelper->expects($this->any())->method('displayPriceExcludingTax')->will($this->returnValue($priceDisplay == TaxConfig::DISPLAY_TYPE_EXCLUDING_TAX)); $taxHelper->expects($this->any())->method('priceIncludesTax')->will($this->returnValue(true)); $responseObject = $this->getMock('Magento\\Framework\\Event\\Observer', ['getResponseObject'], [], '', false); $responseObject->expects($this->any())->method('getResponseObject')->will($this->returnValue($configObj)); $observerObject = $this->getMock('Magento\\Framework\\Event\\Observer', ['getEvent'], [], '', false); $observerObject->expects($this->any())->method('getEvent')->will($this->returnValue($responseObject)); $product = $this->getMock('\\Magento\\Bundle\\Model\\Product\\Type', ['getTypeId', 'getStoreId'], [], '', false); $product->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); $product->expects($this->any())->method('getTypeId')->will($this->returnValue('bundle')); $registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false); $registry->expects($this->any())->method('registry')->with('current_product')->will($this->returnValue($product)); $objectManager = new ObjectManager($this); /** @var \Magento\Weee\Observer\UpdateProductOptionsObserver $weeeObserverObject */ $weeeObserverObject = $objectManager->getObject('Magento\\Weee\\Observer\\UpdateProductOptionsObserver', ['weeeData' => $weeeHelper, 'taxData' => $taxHelper, 'registry' => $registry]); $weeeObserverObject->execute($observerObject); $this->assertEquals($expectedArray, $configObj->getData('additional_options')); }
public function setUp() { $this->validatorMock = $this->getMockBuilder('Magento\\Framework\\Session\\Config\\Validator\\CookieLifetimeValidator')->disableOriginalConstructor()->getMock(); $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\Module\\Resource')->disableOriginalConstructor('delete')->getMock(); $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject('Magento\\Cookie\\Model\\Config\\Backend\\Lifetime', ['configValidator' => $this->validatorMock, 'resource' => $this->resourceMock]); }
protected function setUp() { $this->filter = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Layer\\Filter\\FilterInterface')->disableOriginalConstructor()->setMethods([])->getMockForAbstractClass(); $this->resource = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Layer\\Filter\\Decimal')->disableOriginalConstructor()->setMethods(['getMinMax', 'getCount'])->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject('Magento\\Catalog\\Model\\Layer\\Filter\\DataProvider\\Decimal', ['resource' => $this->resource]); }
protected function setUp() { $this->database = $this->getMockBuilder('Tobai\\GeoIp2\\Model\\Database')->disableOriginalConstructor()->getMock(); $this->objectManager = $this->getMockBuilder('Magento\\Framework\\ObjectManagerInterface')->disableOriginalConstructor()->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->readerFactory = $objectManagerHelper->getObject('Tobai\\GeoIp2\\Model\\Database\\ReaderFactory', ['database' => $this->database, 'objectManager' => $this->objectManager, 'instanceName' => $this->instanceName]); }
protected function setUp() { $objectManager = new ObjectManager($this); $this->paymentDataMock = $this->getMockBuilder('Magento\\Payment\\Helper\\Data')->disableOriginalConstructor()->setMethods(['getMethodInstance'])->getMock(); $this->paymentMethodInstanceMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods(['setStore', 'getCode', 'getFormBlockType', 'getTitle', 'getStore', 'initBillingAgreementToken', 'getBillingAgreementTokenInfo', 'placeBillingAgreement'])->getMock(); $this->model = $objectManager->getObject('Magento\\Paypal\\Model\\Billing\\Agreement', ['paymentData' => $this->paymentDataMock]); }
public function setUp() { $this->registry = $this->getMockBuilder('Magento\\Framework\\Registry')->disableOriginalConstructor()->getMock(); $this->formFactory = $this->getMockBuilder('Magento\\Framework\\Data\\FormFactory')->disableOriginalConstructor()->getMock(); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->object = $this->objectManagerHelper->getObject('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Extend', ['registry' => $this->registry, 'formFactory' => $this->formFactory]); }