Exemplo n.º 1
0
 public function testGetDefaultDashInterval()
 {
     $helper = $this->helper;
     $defaultDashInterval = 4;
     $this->scopeConfig->expects($this->once())->method('getValue')->with($helper::XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue($defaultDashInterval));
     $this->assertEquals($defaultDashInterval, $helper->getDefaultDashInterval());
 }
 /**
  * Check whether value differs from parent scope's one
  *
  * @param string $value
  * @param string $scope
  * @param int $scopeId
  * @param string $path
  * @return bool
  */
 public function isDifferentFromDefault($value, $scope, $scopeId, $path)
 {
     list($scope, $scopeId) = $this->fallbackResolver->getFallbackScope($scope, $scopeId);
     if ($scope) {
         return !$this->isEqual($this->valueProcessor->process($value, $path), $this->valueProcessor->process($this->appConfig->getValue($path, $scope, $scopeId), $path));
     }
     return true;
 }
Exemplo n.º 3
0
 public function testIsDifferentFromDefaultWithArrays()
 {
     $path = 'design/head/default_title';
     $this->fallbackResolver->expects($this->once())->method('getFallbackScope')->with('website', 1)->willReturn(['default', 0]);
     $this->appConfig->expects($this->once())->method('getValue')->with($path, 'default', 0)->willReturn([['qwe' => 123]]);
     $this->valueProcessor->expects($this->atLeastOnce())->method('process')->willReturnArgument(0);
     $this->assertTrue($this->valueChecker->isDifferentFromDefault([['sdf' => 1]], 'website', 1, ['path' => $path]));
 }
 public function testIsDifferentFromDefaultWithWebsiteScope()
 {
     $valueChecker = new ValueChecker($this->fallbackResolver, $this->appConfig, $this->valueProcessor);
     $this->fallbackResolver->expects($this->once())->method('getFallbackScope')->with('website', 1)->willReturn(['default', 0]);
     $this->appConfig->expects($this->once())->method('getValue')->with('design/head/default_title', 'default', 0)->willReturn('');
     $this->valueProcessor->expects($this->atLeastOnce())->method('process')->willReturnArgument(0);
     $this->assertTrue($valueChecker->isDifferentFromDefault('value', 'website', 1, 'design/head/default_title'));
 }
 /**
  * @param int $value
  * @param int $oldValue
  * @param string $eventName
  * @dataProvider testAfterSaveDataProvider
  * @return void
  */
 public function testAfterSave($value, $oldValue, $eventName)
 {
     $path = 'dev/grid/async_indexing';
     $scope = \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
     $this->object->setData(['value' => $value, 'path' => $path, 'scope' => $scope]);
     $this->config->expects($this->once())->method('getValue')->with($path, $scope)->willReturn($oldValue);
     if ($value == $oldValue) {
         $this->eventManager->expects($this->never())->method('dispatch');
     } else {
         $this->eventManager->expects($this->once())->method('dispatch')->with($eventName);
     }
     $this->object->afterSave();
 }
Exemplo n.º 6
0
 protected function setUp()
 {
     $this->locale = $this->getMock('Magento\\Framework\\Locale', ['getTranslation', 'toString'], [], '', false);
     $this->dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime', ['isEmptyDate'], [], '', false);
     $this->scopeConfig = $this->getMock('Magento\\Framework\\App\\Config', ['getValue'], [], '', false);
     $this->localeResolver = $this->getMock('Magento\\Backend\\Model\\Locale\\Resolver', ['getLocale'], [], '', false);
     $this->dateFactory = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\DateFactory', ['create'], [], '', false);
     $this->scopeResolver = $this->getMock('Magento\\Store\\Model\\Resolver\\Store', ['getScope'], [], '', false);
     $this->localeResolver->expects($this->any())->method('getLocale')->will($this->returnValue($this->locale));
     $this->scopeConfig->expects($this->any())->method('getValue')->with(\Magento\Core\Helper\Data::XML_PATH_DEFAULT_TIMEZONE, 'store')->will($this->returnValue('America/Los_Angeles'));
     $this->locale->expects($this->any())->method('toString')->will($this->returnValue('en_US'));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->timezone = $objectManager->getObject('Magento\\Framework\\Stdlib\\DateTime\\Timezone', ['scopeResolver' => $this->scopeResolver, 'localeResolver' => $this->localeResolver, 'dateTime' => $this->dateTime, 'dateFactory' => $this->dateFactory, 'scopeConfig' => $this->scopeConfig, 'scopeType' => 'store', 'defaultTimezonePath' => \Magento\Core\Helper\Data::XML_PATH_DEFAULT_TIMEZONE]);
 }
 public function testGetMerchantId()
 {
     $this->sessionQuote->expects($this->once())->method('getStoreId')->willReturn(1);
     $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(1);
     $result = $this->model->getMerchantId();
     $this->assertEquals(1, $result);
 }
Exemplo n.º 8
0
 public function testGetLifetimeFrontend()
 {
     $areaCode = 'frontend';
     $expectedLifetime = 234;
     $this->appStateMock->expects($this->once())->method('getAreaCode')->willReturn($areaCode);
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with(Config::XML_PATH_COOKIE_LIFETIME, ScopeInterface::SCOPE_STORE)->willReturn($expectedLifetime);
     $this->assertEquals($this->config->getLifetime(), $expectedLifetime);
 }
Exemplo n.º 9
0
 /**
  * @param bool $useConfigMinQty
  * @param float $minQty
  * @dataProvider setMinQtyDataProvider
  */
 public function testSetMinQty($useConfigMinQty, $minQty)
 {
     $this->setDataArrayValue('use_config_min_qty', $useConfigMinQty);
     if ($useConfigMinQty) {
         $this->scopeConfig->expects($this->any())->method('getValue')->with($this->equalTo(Item::XML_PATH_MIN_QTY), $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE))->will($this->returnValue($minQty));
     } else {
         $this->setDataArrayValue('min_qty', $minQty);
     }
     $this->assertSame($minQty, $this->item->getMinQty());
 }
 /**
  * @param int $configValue
  * @param array|null $collectionItems
  * @param bool|null $emailSendingResult
  * @dataProvider executeDataProvider
  * @return void
  */
 public function testExecute($configValue, $collectionItems, $emailSendingResult)
 {
     $path = 'sales_email/general/async_sending';
     $this->globalConfig->expects($this->once())->method('getValue')->with($path)->willReturn($configValue);
     if ($configValue) {
         $this->entityCollection->expects($this->at(0))->method('addFieldToFilter')->with('send_email', ['eq' => 1]);
         $this->entityCollection->expects($this->at(1))->method('addFieldToFilter')->with('email_sent', ['null' => true]);
         $this->entityCollection->expects($this->any())->method('getItems')->willReturn($collectionItems);
         if ($collectionItems) {
             /** @var \Magento\Sales\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject $collectionItem */
             $collectionItem = $collectionItems[0];
             $this->emailSender->expects($this->once())->method('send')->with($collectionItem, true)->willReturn($emailSendingResult);
             if ($emailSendingResult) {
                 $collectionItem->expects($this->once())->method('setEmailSent')->with(true)->willReturn($collectionItem);
                 $this->entityResource->expects($this->once())->method('save')->with($collectionItem);
             }
         }
     }
     $this->object->sendEmails();
 }
Exemplo n.º 11
0
 protected function generalGetProductCollection()
 {
     $this->eventManager->expects($this->once())->method('dispatch')->will($this->returnValue(true));
     $this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()->willReturn(false);
     $this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters()->willReturn(false);
     $this->catalogConfig->expects($this->once())->method('getProductAttributes')->willReturn([]);
     $this->localDate->expects($this->any())->method('date')->willReturn(new \DateTime('now', new \DateTimeZone('UTC')));
     $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager);
     $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig);
     $this->context->expects($this->once())->method('getCacheState')->willReturn($this->cacheState);
     $this->context->expects($this->once())->method('getCatalogConfig')->willReturn($this->catalogConfig);
     $this->context->expects($this->once())->method('getLocaleDate')->willReturn($this->localDate);
     $this->productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection')->setMethods(['setVisibility', 'addMinimalPrice', 'addFinalPrice', 'addTaxPercents', 'addAttributeToSelect', 'addUrlRewrite', 'addStoreFilter', 'addAttributeToSort', 'setPageSize', 'setCurPage', 'addAttributeToFilter'])->disableOriginalConstructor()->getMock();
     $this->productCollection->expects($this->once())->method('setVisibility')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addMinimalPrice')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addFinalPrice')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addTaxPercents')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addAttributeToSelect')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addUrlRewrite')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addStoreFilter')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addAttributeToSort')->willReturnSelf();
     $this->productCollection->expects($this->atLeastOnce())->method('setCurPage')->willReturnSelf();
     $this->productCollection->expects($this->any())->method('addAttributeToFilter')->willReturnSelf();
 }