Esempio n. 1
0
 protected function setUp()
 {
     $this->managerInterface = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $this->reviewFactory = $this->getMock('Magento\\Review\\Model\\ReviewFactory', ['create'], [], '', false);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->rss = $this->objectManagerHelper->getObject('Magento\\Review\\Model\\Rss', ['eventManager' => $this->managerInterface, 'reviewFactory' => $this->reviewFactory]);
 }
 /**
  * @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
  */
 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])));
 }
Esempio n. 4
0
 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]);
 }
Esempio n. 5
0
 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]);
 }
 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]);
 }
Esempio n. 7
0
 /**
  * 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();
 }
Esempio n. 8
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManagerHelper($this);
     $this->dataProviderMock = $this->getMockBuilder(ModifierInterface::class)->getMockForAbstractClass();
     $this->objectManagerMock = $this->getMockBuilder(ObjectManager::class)->disableOriginalConstructor()->getMock();
     $this->model = $this->objectManager->getObject(\Magento\Ui\DataProvider\Modifier\ModifierFactory::class, ['objectManager' => $this->objectManagerMock]);
 }
 protected function setUp()
 {
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->pageFactory = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Result\\PageFactory', ['objectManager' => $this->objectManagerMock]);
     $this->page = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
 }
 /**
  * @return AbstractElement
  */
 protected function getModel()
 {
     if (null === $this->model) {
         $this->model = $this->objectManager->getObject($this->getModelName(), ['context' => $this->contextMock]);
     }
     return $this->model;
 }
 /**
  * Setup the test
  */
 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false);
     $this->customerResourceModel = $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false);
     $this->model = $this->objectManager->getObject(\Magento\Customer\Model\CustomerAuthUpdate::class, ['customerRegistry' => $this->customerRegistry, 'customerResourceModel' => $this->customerResourceModel]);
 }
Esempio n. 12
0
 public function setUp()
 {
     $context = $this->getMock('Magento\\Backend\\Block\\Template\\Context', [], [], '', false);
     $eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $context->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager));
     $scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], [], '', false);
     $context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig));
     $this->request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', ['getStores', 'getDefaultStoreView'], [], '', false);
     $context->expects($this->once())->method('getStoreManager')->will($this->returnValue($this->storeManager));
     $appState = $this->getMock('Magento\\Framework\\App\\State', [], [], '', false);
     $context->expects($this->once())->method('getAppState')->will($this->returnValue($appState));
     $templateFactory = $this->getMock('Magento\\Newsletter\\Model\\TemplateFactory', ['create'], [], '', false);
     $this->template = $this->getMock('Magento\\Newsletter\\Model\\Template', [], [], '', false);
     $templateFactory->expects($this->once())->method('create')->will($this->returnValue($this->template));
     $subscriberFactory = $this->getMock('Magento\\Newsletter\\Model\\SubscriberFactory', ['create'], [], '', false);
     $this->subscriber = $this->getMock('Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $subscriberFactory->expects($this->once())->method('create')->will($this->returnValue($this->subscriber));
     $queueFactory = $this->getMock('Magento\\Newsletter\\Model\\QueueFactory', ['create'], [], '', false);
     $this->queue = $this->getMock('Magento\\Newsletter\\Model\\Queue', ['load'], [], '', false);
     $queueFactory->expects($this->any())->method('create')->will($this->returnValue($this->queue));
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->preview = $this->objectManager->getObject('Magento\\Newsletter\\Block\\Adminhtml\\Queue\\Preview', ['context' => $context, 'templateFactory' => $templateFactory, 'subscriberFactory' => $subscriberFactory, 'queueFactory' => $queueFactory]);
 }
 protected function setUp()
 {
     $this->configMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\Config\\Cc')->disableOriginalConstructor()->getMock();
     $this->transactionFactoryMock = $this->getMockBuilder('\\Magento\\Framework\\DB\\TransactionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->processBraintreePaymentObserver = $this->objectManagerHelper->getObject('Magento\\Braintree\\Observer\\ProcessBraintreePayment', ['config' => $this->configMock, 'transactionFactory' => $this->transactionFactoryMock]);
 }
Esempio n. 14
0
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManager($this);
     /** @var Context $context */
     $this->context = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Element\\Template\\Context');
     $this->block = new Links($this->context);
 }
Esempio n. 15
0
 /**
  * @dataProvider getPropertiesDataProvider
  */
 public function testGetProperties($queryText, $resultsCount)
 {
     /** @var \Magento\Search\Model\QueryResult $queryResult */
     $queryResult = $this->objectManager->getObject('Magento\\Search\\Model\\QueryResult', ['queryText' => $queryText, 'resultsCount' => $resultsCount]);
     $this->assertEquals($queryText, $queryResult->getQueryText());
     $this->assertEquals($resultsCount, $queryResult->getResultsCount());
 }
Esempio n. 16
0
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->helperMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ScheduledStructure\\Helper')->disableOriginalConstructor()->getMock();
     $this->readerPoolMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ReaderPool')->disableOriginalConstructor()->getMock();
     $this->container = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Layout\\Reader\\Container', ['helper' => $this->helperMock, 'readerPool' => $this->readerPoolMock]);
 }
Esempio n. 17
0
 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]);
 }
 /**
  * @param bool $isSecure
  * @param array $metadata
  * @param bool $expected
  * @param int $callNum
  * @dataProvider toArrayDataProvider
  */
 public function testToArray($isSecure, $metadata, $expected, $callNum = 1)
 {
     $this->requestMock->expects($this->exactly($callNum))->method('isSecure')->willReturn($isSecure);
     /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */
     $object = $this->objectManager->getObject('Magento\\Framework\\Stdlib\\Cookie\\SensitiveCookieMetadata', ['request' => $this->requestMock, 'metadata' => $metadata]);
     $this->assertEquals($expected, $object->__toArray());
 }
 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]);
 }
Esempio n. 20
0
 public function testPrepareLayout()
 {
     $allowCurrencies = ['EUR', 'UAH', 'USD'];
     $baseCurrencies = ['USD'];
     $currencyRates = ['USD' => ['EUR' => -1, 'UAH' => 21.775, 'GBP' => 12, 'USD' => 1]];
     $expectedCurrencyRates = ['USD' => ['EUR' => null, 'UAH' => '21.7750', 'GBP' => '12.0000', 'USD' => '1.0000']];
     $newRates = ['USD' => ['EUR' => 0.7766999999999999, 'UAH' => 20, 'GBP' => 12, 'USD' => 1]];
     $expectedNewRates = ['USD' => ['EUR' => '0.7767', 'UAH' => '20.0000', 'GBP' => '12.0000', 'USD' => '1.0000']];
     $backendSessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['getRates', 'unsetData'], [], '', false);
     $backendSessionMock->expects($this->once())->method('getRates')->willReturn($newRates);
     $currencyFactoryMock = $this->getMock('Magento\\Directory\\Model\\CurrencyFactory', ['create'], [], '', false);
     $currencyMock = $this->getMock('Magento\\Directory\\Model\\Currency', ['getConfigAllowCurrencies', 'getConfigBaseCurrencies', 'getCurrencyRates'], [], '', false);
     $currencyFactoryMock->expects($this->once())->method('create')->willReturn($currencyMock);
     $currencyMock->expects($this->once())->method('getConfigAllowCurrencies')->willReturn($allowCurrencies);
     $currencyMock->expects($this->once())->method('getConfigBaseCurrencies')->willReturn($baseCurrencies);
     $currencyMock->expects($this->once())->method('getCurrencyRates')->with($baseCurrencies, $allowCurrencies)->willReturn($currencyRates);
     /** @var $layoutMock \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject */
     $layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false, false, true, []);
     /** @var $block \Magento\CurrencySymbol\Block\Adminhtml\System\Currency\Rate\Services */
     $block = $this->objectManagerHelper->getObject('Magento\\CurrencySymbol\\Block\\Adminhtml\\System\\Currency\\Rate\\Matrix', ['dirCurrencyFactory' => $currencyFactoryMock, 'backendSession' => $backendSessionMock]);
     $block->setLayout($layoutMock);
     $this->assertEquals($allowCurrencies, $block->getAllowedCurrencies());
     $this->assertEquals($baseCurrencies, $block->getDefaultCurrencies());
     $this->assertEquals($expectedCurrencyRates, $block->getOldRates());
     $this->assertEquals($expectedNewRates, $block->getNewRates());
 }
Esempio n. 21
0
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->filePath = __DIR__ . '/_files/';
     $this->source = new \DOMDocument();
     $this->model = $this->objectManagerHelper->getObject(Converter::class);
 }
 /**
  * @return void
  */
 protected function setUp()
 {
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->stateMock = $this->getMock('Magento\\Framework\\App\\State', [], [], '', false);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->dataStructure = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Layout\\Data\\Structure', ['logger' => $this->loggerMock, 'state' => $this->stateMock]);
 }
Esempio n. 23
0
 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]);
 }
 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->paymentHelperMock = $this->getMock('\\Magento\\Payment\\Helper\\Data', [], [], '', false);
     $this->specificationFactoryMock = $this->getMock('\\Magento\\Payment\\Model\\Checks\\SpecificationFactory', [], [], '', false);
     $this->methodList = $this->objectManager->getObject('Magento\\Payment\\Model\\MethodList', ['paymentHelper' => $this->paymentHelperMock, 'specificationFactory' => $this->specificationFactoryMock]);
 }
 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']]);
 }
Esempio n. 26
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->totalsMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address\\Total', [], [], '', false);
     $this->shippingAssignmentMock = $this->getMock('Magento\\Quote\\Api\\Data\\ShippingAssignmentInterface');
     $this->shippingMock = $this->getMock('Magento\\Quote\\Api\\Data\\ShippingInterface');
     $this->taxConfigMock = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['priceIncludesTax', 'getShippingTaxClass', 'shippingPriceIncludesTax', 'discountTax'])->getMock();
     $this->taxCalculationMock = $this->getMockBuilder('Magento\\Tax\\Api\\TaxCalculationInterface')->getMockForAbstractClass();
     $this->quoteDetailsDataObjectFactoryMock = $this->getMockBuilder('\\Magento\\Tax\\Api\\Data\\QuoteDetailsInterfaceFactory')->disableOriginalConstructor()->setMethods(['create', 'setBillingAddress', 'setShippingAddress'])->getMock();
     $this->keyDataObjectFactoryMock = $this->getMock('Magento\\Tax\\Api\\Data\\TaxClassKeyInterfaceFactory', ['create'], [], '', false);
     $customerAddressMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false);
     $customerAddressFactoryMock = $this->getMock('Magento\\Customer\\Api\\Data\\AddressInterfaceFactory', ['create'], [], '', false);
     $customerAddressFactoryMock->expects($this->any())->method('create')->willReturn($customerAddressMock);
     $customerAddressRegionMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\RegionInterface', [], '', false);
     $customerAddressRegionMock->expects($this->any())->method('setRegionId')->willReturnSelf();
     $customerAddressRegionFactoryMock = $this->getMock('Magento\\Customer\\Api\\Data\\RegionInterfaceFactory', ['create'], [], '', false);
     $customerAddressRegionFactoryMock->expects($this->any())->method('create')->willReturn($customerAddressRegionMock);
     $this->model = $this->objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\Subtotal', ['taxConfig' => $this->taxConfigMock, 'taxCalculationService' => $this->taxCalculationMock, 'quoteDetailsDataObjectFactory' => $this->quoteDetailsDataObjectFactoryMock, 'taxClassKeyDataObjectFactory' => $this->keyDataObjectFactoryMock, 'customerAddressFactory' => $customerAddressFactoryMock, 'customerAddressRegionFactory' => $customerAddressRegionFactoryMock]);
     $this->addressMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address')->disableOriginalConstructor()->setMethods(['getAssociatedTaxables', 'getQuote', 'getBillingAddress', 'getRegionId', 'getAllItems', '__wakeup', 'getParentItem'])->getMock();
     $this->quoteMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $this->addressMock->expects($this->any())->method('getQuote')->willReturn($this->quoteMock);
     $this->storeMock = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->quoteMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getStoreId')->willReturn(111);
 }
Esempio n. 27
0
 /**
  * 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);
 }
Esempio n. 28
0
 /**
  * Check of processing email templates
  *
  * @param array $requestParamMap
  *
  * @dataProvider toHtmlDataProvider
  * @param $requestParamMap
  */
 public function testToHtml($requestParamMap)
 {
     $storeId = 1;
     $template = $this->getMockBuilder('Magento\\Email\\Model\\Template')->setMethods(['setDesignConfig', 'getDesignConfig', '__wakeup', 'getProcessedTemplate', 'getAppState', 'revertDesign'])->disableOriginalConstructor()->getMock();
     $template->expects($this->once())->method('getProcessedTemplate')->with($this->equalTo([]))->willReturn(self::MALICIOUS_TEXT);
     $designConfigData = [];
     $template->expects($this->atLeastOnce())->method('getDesignConfig')->willReturn(new \Magento\Framework\DataObject($designConfigData));
     $emailFactory = $this->getMock('Magento\\Email\\Model\\TemplateFactory', ['create'], [], '', false);
     $emailFactory->expects($this->any())->method('create')->willReturn($template);
     $request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $request->expects($this->any())->method('getParam')->willReturnMap($requestParamMap);
     $eventManage = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $design = $this->getMock('Magento\\Framework\\View\\DesignInterface');
     $store = $this->getMock('Magento\\Store\\Model\\Store', ['getId', '__wakeup'], [], '', false);
     $store->expects($this->any())->method('getId')->willReturn($storeId);
     $storeManager = $this->getMockBuilder('\\Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
     $storeManager->expects($this->atLeastOnce())->method('getDefaultStoreView')->willReturn($store);
     $storeManager->expects($this->any())->method('getDefaultStoreView')->willReturn(null);
     $storeManager->expects($this->any())->method('getStores')->willReturn([$store]);
     $appState = $this->getMockBuilder('Magento\\Framework\\App\\State')->setConstructorArgs([$scopeConfig])->setMethods(null)->disableOriginalConstructor()->getMock();
     $context = $this->getMock('Magento\\Backend\\Block\\Template\\Context', ['getRequest', 'getEventManager', 'getScopeConfig', 'getDesignPackage', 'getStoreManager', 'getAppState'], [], '', false);
     $context->expects($this->any())->method('getRequest')->willReturn($request);
     $context->expects($this->any())->method('getEventManager')->willReturn($eventManage);
     $context->expects($this->any())->method('getScopeConfig')->willReturn($scopeConfig);
     $context->expects($this->any())->method('getDesignPackage')->willReturn($design);
     $context->expects($this->any())->method('getStoreManager')->willReturn($storeManager);
     $context->expects($this->once())->method('getAppState')->willReturn($appState);
     $maliciousCode = $this->getMock('Magento\\Framework\\Filter\\Input\\MaliciousCode', ['filter'], [], '', false);
     $maliciousCode->expects($this->once())->method('filter')->with($this->equalTo($requestParamMap[1][2]))->willReturn(self::MALICIOUS_TEXT);
     /** @var \Magento\Email\Block\Adminhtml\Template\Preview $preview */
     $preview = $this->objectManagerHelper->getObject('Magento\\Email\\Block\\Adminhtml\\Template\\Preview', ['context' => $context, 'maliciousCode' => $maliciousCode, 'emailFactory' => $emailFactory]);
     $this->assertEquals(self::MALICIOUS_TEXT, $preview->toHtml());
 }
 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]);
 }
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $rendererMock = $this->getMockBuilder('Magento\\Config\\Block\\System\\Config\\Form\\Field')->disableOriginalConstructor()->getMock();
     $this->layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock();
     $this->layoutMock->expects($this->any())->method('getBlockSingleton')->willReturn($rendererMock);
     $this->jsHelperMock = $this->getMockBuilder('Magento\\Framework\\View\\Helper\\Js')->disableOriginalConstructor()->getMock();
     $this->moduleListMock = $this->getMockBuilder('Magento\\Framework\\Module\\ModuleListInterface')->setMethods(['getNames', 'has', 'getAll', 'getOne'])->disableOriginalConstructor()->getMock();
     $this->moduleListMock->expects($this->any())->method('getNames')->will($this->returnValue(['Test Name']));
     $this->moduleListMock->expects($this->any())->method('has')->will($this->returnValue(true));
     $this->moduleListMock->expects($this->any())->method('getAll')->will($this->returnValue([]));
     $this->moduleListMock->expects($this->any())->method('getOne')->will($this->returnValue(null));
     $this->authSessionMock = $this->getMockBuilder('Magento\\Backend\\Model\\Auth\\Session')->setMethods(['getUser'])->disableOriginalConstructor()->getMock();
     $this->userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->setMethods(['getExtra'])->disableOriginalConstructor()->getMock();
     $this->authSessionMock->expects($this->any())->method('getUser')->willReturn($this->userMock);
     $groupMock = $this->getMockBuilder('Magento\\Config\\Model\\Config\\Structure\\Element\\Group')->setMethods(['getFieldsetCss'])->disableOriginalConstructor()->getMock();
     $groupMock->expects($this->any())->method('getFieldsetCss')->will($this->returnValue('test_fieldset_css'));
     $factory = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\Element\\Factory')->disableOriginalConstructor()->getMock();
     $factoryColl = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\Element\\CollectionFactory')->disableOriginalConstructor()->getMock();
     $formMock = $this->getMock('Magento\\Framework\\Data\\Form\\AbstractForm', [], [$factory, $factoryColl]);
     $context = $this->objectManager->getObject('Magento\\Backend\\Block\\Context', ['layout' => $this->layoutMock]);
     $data = ['context' => $context, 'authSession' => $this->authSessionMock, 'jsHelper' => $this->jsHelperMock, 'moduleList' => $this->moduleListMock, 'data' => ['group' => $groupMock, 'form' => $formMock]];
     $this->object = $this->objectManager->getObject('Magento\\Config\\Block\\System\\Config\\Form\\Fieldset\\Modules\\DisableOutput', $data);
     $this->elementMock = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\Element\\Text')->setMethods(['getId', 'getHtmlId', 'getName', 'getExpanded', 'getLegend', 'getComment', 'getTooltip', 'toHtml', 'addField', 'setRenderer', 'getElements', 'getIsNested'])->disableOriginalConstructor()->disableOriginalClone()->enableAutoload()->getMock();
     $this->elementMock->expects($this->any())->method('getId')->will($this->returnValue($this->elementData['htmlId']));
     $this->elementMock->expects($this->any())->method('getHtmlId')->will($this->returnValue($this->elementData['htmlId']));
     $this->elementMock->expects($this->any())->method('getName')->will($this->returnValue($this->elementData['name']));
     $this->elementMock->expects($this->any())->method('getLegend')->will($this->returnValue($this->elementData['legend']));
     $this->elementMock->expects($this->any())->method('getComment')->will($this->returnValue($this->elementData['comment']));
     $this->elementMock->expects($this->any())->method('getTooltip')->will($this->returnValue($this->elementData['tooltip']));
     $this->elementMock->expects($this->any())->method('toHtml')->will($this->returnValue($this->elementData['elementHTML']));
     $this->elementMock->expects($this->any())->method('addField')->will($this->returnValue($this->elementMock));
     $this->elementMock->expects($this->any())->method('setRenderer')->will($this->returnValue($this->elementMock));
     $this->elementMock->expects($this->any())->method('getElements')->will($this->returnValue([$this->elementMock]));
 }