Beispiel #1
0
 /**
  * Run test getAllIds method
  *
  * @return void
  */
 public function testGetAllIds()
 {
     $adapterMock = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', [], '', false, true, true, ['fetchCol']);
     $this->resourceMock->expects($this->once())->method('getIdFieldName')->will($this->returnValue('return-value'));
     $this->selectMock->expects($this->once())->method('getAdapter')->will($this->returnValue($adapterMock));
     $adapterMock->expects($this->once())->method('fetchCol')->will($this->returnValue('fetch-result'));
     $this->assertEquals('fetch-result', $this->query->getAllIds());
 }
Beispiel #2
0
 /**
  * @expectedException \Exception
  */
 public function testDeleteRaiseException()
 {
     $this->actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true));
     $this->adapterMock->expects($this->once())->method('beginTransaction');
     $this->resourceMock->expects($this->once())->method('delete')->will($this->throwException(new \Exception()));
     $this->resourceMock->expects($this->never())->method('commit');
     $this->resourceMock->expects($this->once())->method('rollBack');
     $this->model->delete();
 }
Beispiel #3
0
 /**
  * Returns list of columns from fulltext index (doesn't support more then one FTI per table)
  *
  * @param DbResource $resource
  * @param string $indexTable
  * @return array
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function getFulltextIndexColumns(DbResource $resource, $indexTable)
 {
     $indexes = $resource->getReadConnection()->getIndexList($indexTable);
     foreach ($indexes as $index) {
         if (strtoupper($index['INDEX_TYPE']) == 'FULLTEXT') {
             return $index['COLUMNS_LIST'];
         }
     }
     return [];
 }
 /**
  * Test that the model detects a connection when it becomes active
  */
 public function testGetConnectionInMemoryCaching()
 {
     $string = $this->getMock('Magento\\Framework\\Stdlib\\String', [], [], '', false);
     $dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime', null, [], '', true);
     $logger = $this->getMockForAbstractClass('Magento\\Framework\\DB\\LoggerInterface');
     $connection = new \Magento\Framework\DB\Adapter\Pdo\Mysql($string, $dateTime, $logger, ['dbname' => 'test_dbname', 'username' => 'test_username', 'password' => 'test_password']);
     $this->_resource->expects($this->atLeastOnce())->method('getConnection')->with('core_read')->will($this->onConsecutiveCalls(false, $connection, false));
     $this->assertFalse($this->_model->getReadConnection());
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Inactive connection should not be cached');
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Active connection should be cached');
 }
Beispiel #5
0
 /**
  * Test that the model detects a connection when it becomes active
  */
 public function testGetConnectionInMemoryCaching()
 {
     $filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false);
     $string = $this->getMock('Magento\\Framework\\Stdlib\\String', array(), array(), '', false);
     $dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime', null, array(), '', true);
     $connection = new \Magento\Framework\DB\Adapter\Pdo\Mysql($filesystem, $string, $dateTime, array('dbname' => 'test_dbname', 'username' => 'test_username', 'password' => 'test_password'));
     $this->_resource->expects($this->atLeastOnce())->method('getConnection')->with('core_read')->will($this->onConsecutiveCalls(false, $connection, false));
     $this->assertFalse($this->_model->getReadConnection());
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Inactive connection should not be cached');
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Active connection should be cached');
 }
 public function testSetMainTable()
 {
     $setMainTableMethod = new \ReflectionMethod($this->_model, '_setMainTable');
     $setMainTableMethod->setAccessible(true);
     $tableName = $this->_model->getTable('store_website');
     $idFieldName = 'website_id';
     $setMainTableMethod->invoke($this->_model, $tableName);
     $this->assertEquals($tableName, $this->_model->getMainTable());
     $setMainTableMethod->invoke($this->_model, $tableName, $idFieldName);
     $this->assertEquals($tableName, $this->_model->getMainTable());
     $this->assertEquals($idFieldName, $this->_model->getIdFieldName());
 }
Beispiel #7
0
 /**
  * Mock class dependencies
  */
 protected function setUp()
 {
     $this->entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', [], [], '', false);
     $this->fetchStrategyMock = $this->getMockForAbstractClass('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface');
     $this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $this->selectMock = $this->getMock('Zend_Db_Select', [], [], '', false);
     $this->connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->connectionMock->expects($this->atLeastOnce())->method('select')->will($this->returnValue($this->selectMock));
     $this->resourceMock = $this->getMock('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getReadConnection')->will($this->returnValue($this->connectionMock));
     $objectManager = new ObjectManager($this);
     $this->collection = $objectManager->getObject('Magento\\Quote\\Model\\Resource\\Quote\\Item\\Collection', ['entityFactory' => $this->entityFactoryMock, 'fetchStrategy' => $this->fetchStrategyMock, 'eventManager' => $this->eventManagerMock, 'resource' => $this->resourceMock]);
 }
 protected function setUp()
 {
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
     $this->select = $this->getMock('Zend_Db_Select', ['from', 'where'], [], '', false);
     $this->adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'prepareSqlCondition', 'quoteIdentifier'], [], '', false);
     $this->resource = $this->getMockForAbstractClass('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', [], '', false, true, true, ['getReadConnection', '__wakeup', 'getMainTable', 'getTable']);
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->adapter->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->adapter->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
     $this->resource->expects($this->any())->method('getReadConnection')->will($this->returnValue($this->adapter));
     $this->resource->expects($this->any())->method('getMainTable')->will($this->returnValue('test_main_table'));
     $this->resource->expects($this->any())->method('getTable')->with('test_main_table')->will($this->returnValue('test_main_table'));
     $this->collection = (new ObjectManager($this))->getObject('Magento\\UrlRewrite\\Model\\Resource\\UrlRewriteCollection', ['storeManager' => $this->storeManager, 'resource' => $this->resource]);
 }
Beispiel #9
0
 /**
  * @param mixed $ignoreData
  * @param 'string' $ignoreSql
  * @dataProvider ignoresDataProvider
  * @return void
  */
 public function testAddStoreFilter($ignoreData, $ignoreSql)
 {
     $typeId = 1;
     $subjectId = 2;
     $subtype = 3;
     $limit = 0;
     $stores = [1, 2];
     $this->resourceMock->expects($this->once())->method('getCurrentStoreIds')->willReturn($stores);
     $this->selectMock->expects($this->at(0))->method('where')->with('event_type_id = ?', $typeId);
     $this->selectMock->expects($this->at(1))->method('where')->with('subject_id = ?', $subjectId);
     $this->selectMock->expects($this->at(2))->method('where')->with('subtype = ?', $subtype);
     $this->selectMock->expects($this->at(3))->method('where')->with('store_id IN(?)', $stores);
     $this->selectMock->expects($this->at(4))->method('where')->with($ignoreSql, $ignoreData);
     $this->collection->addRecentlyFiler($typeId, $subjectId, $subtype, $ignoreData, $limit);
 }
Beispiel #10
0
 protected function setUp()
 {
     $this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategy\\Query', ['fetchAll'], [], '', false);
     $this->entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', ['create'], [], '', false);
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb')->setMethods(['getReadConnection', 'getMainTable', 'getTable'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->adapterMock = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', ['select', 'query'], [], '', false);
     $this->selectMock = $this->getMock('Magento\\Framework\\DB\\Select', ['from'], ['adapter' => $this->adapterMock]);
     $this->adapterMock->expects($this->once())->method('select')->will($this->returnValue($this->selectMock));
     $this->resourceMock->expects($this->once())->method('getReadConnection')->will($this->returnValue($this->adapterMock));
     $this->resourceMock->expects($this->once())->method('getMainTable')->willReturn('main_table_name');
     $this->resourceMock->expects($this->once())->method('getTable')->will($this->returnArgument(0));
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->collection = $objectManager->getObject('Magento\\Review\\Model\\Resource\\Review\\Summary\\Collection', ['entityFactory' => $this->entityFactoryMock, 'logger' => $this->loggerMock, 'fetchStrategy' => $this->fetchStrategyMock, 'resource' => $this->resourceMock]);
 }
Beispiel #11
0
 public function testGetFields()
 {
     $entityTable = 'entity_table';
     $expectedDescribedTable = ['field1' => null, 'field2' => null];
     $expectedAttributes = ['attribute1' => 'value1', 'attribute2' => 'value2'];
     $expectedResults = array_merge($expectedDescribedTable, $expectedAttributes);
     $this->resource->expects($this->any())->method('getEntityTable')->willReturn($entityTable);
     $this->connection->expects($this->once())->method('describeTable')->with($entityTable)->willReturn($expectedDescribedTable);
     $this->model->expects($this->any())->method('getAttributes')->willReturn($expectedAttributes);
     //check that fields load with null initial value
     $this->assertEquals(array_fill_keys(array_keys($expectedResults), null), $this->metadata->getFields($this->model));
     // Testing loading data from cache.
     $this->connection->expects($this->never())->method('describeTable');
     $this->assertEquals(array_fill_keys(array_keys($expectedResults), null), $this->metadata->getFields($this->model));
 }
Beispiel #12
0
 /**
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param \Magento\Customer\Model\Session $customerSession
  * @param \Magento\Review\Model\Rating\Option\VoteFactory $ratingOptionVoteF
  * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Review\Model\Rating\Option\VoteFactory $ratingOptionVoteF, \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, $resourcePrefix = null)
 {
     $this->_customerSession = $customerSession;
     $this->_ratingOptionVoteF = $ratingOptionVoteF;
     $this->_remoteAddress = $remoteAddress;
     parent::__construct($context, $resourcePrefix);
 }
Beispiel #13
0
 /**
  * Construct
  *
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility
  * @param Advanced $searchResource
  * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\CatalogSearch\Model\Resource\Advanced $searchResource, \Magento\CatalogSearch\Helper\Data $catalogSearchData, $resourcePrefix = null)
 {
     $this->_catalogProductVisibility = $catalogProductVisibility;
     $this->_searchResource = $searchResource;
     $this->_catalogSearchData = $catalogSearchData;
     parent::__construct($context, $resourcePrefix);
 }
Beispiel #14
0
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Store\Model\WebsiteFactory $websiteFactory
  * @param \Magento\Eav\Model\Config $eavConfig
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Eav\Model\Config $eavConfig)
 {
     parent::__construct($resource);
     $this->_storeManager = $storeManager;
     $this->_websiteFactory = $websiteFactory;
     $this->eavConfig = $eavConfig;
 }
Beispiel #15
0
 /**
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param \Magento\Framework\Stdlib\DateTime\DateTime $date
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\Stdlib\DateTime $dateTime
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Stdlib\DateTime $dateTime, $resourcePrefix = null)
 {
     $this->_date = $date;
     $this->_eventManager = $eventManager;
     $this->dateTime = $dateTime;
     parent::__construct($context, $resourcePrefix);
 }
Beispiel #16
0
 /**
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Store\Model\WebsiteFactory $websiteFactory
  * @param \Magento\Eav\Model\Config $eavConfig
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Eav\Model\Config $eavConfig, $resourcePrefix = null)
 {
     parent::__construct($context, $resourcePrefix);
     $this->_storeManager = $storeManager;
     $this->_websiteFactory = $websiteFactory;
     $this->eavConfig = $eavConfig;
 }
Beispiel #17
0
 /**
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\Filter\FilterManager $filter
  * @param Helper $resourceHelper
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Filter\FilterManager $filter, \Magento\Search\Model\Resource\Helper $resourceHelper, $resourcePrefix = null)
 {
     $this->_eventManager = $eventManager;
     $this->filter = $filter;
     $this->_resourceHelper = $resourceHelper;
     parent::__construct($context, $resourcePrefix);
 }
Beispiel #18
0
 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($date = $object->getDateFrom()) {
         $object->setDateFrom($this->dateTime->formatDate($date));
     } else {
         $object->setDateFrom(null);
     }
     if ($date = $object->getDateTo()) {
         $object->setDateTo($this->dateTime->formatDate($date));
     } else {
         $object->setDateTo(null);
     }
     if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && (new \DateTime($object->getDateFrom()))->getTimestamp() > (new \DateTime($object->getDateTo()))->getTimestamp()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The start date can\'t follow the end date.'));
     }
     $check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
     if ($check) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The date range for this design change overlaps another design change for the specified store.'));
     }
     if ($object->getDateFrom() === null) {
         $object->setDateFrom(new \Zend_Db_Expr('null'));
     }
     if ($object->getDateTo() === null) {
         $object->setDateTo(new \Zend_Db_Expr('null'));
     }
     parent::_beforeSave($object);
 }
Beispiel #19
0
 /**
  * Delete all Nonce entries associated with the consumer
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 public function _afterDelete(\Magento\Framework\Model\AbstractModel $object)
 {
     $adapter = $this->_getWriteAdapter();
     $adapter->delete($this->getTable('oauth_nonce'), array('consumer_id' => $object->getId()));
     $adapter->delete($this->getTable('oauth_token'), array('consumer_id' => $object->getId()));
     return parent::_afterDelete($object);
 }
Beispiel #20
0
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Framework\Stdlib\DateTime\DateTime $date
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\Stdlib\DateTime $dateTime
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Stdlib\DateTime $dateTime)
 {
     $this->_date = $date;
     $this->_eventManager = $eventManager;
     $this->dateTime = $dateTime;
     parent::__construct($resource);
 }
Beispiel #21
0
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
  * @param null|string $scope
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\App\State $appState, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, $scope = null)
 {
     $this->_appState = $appState;
     $this->scopeResolver = $scopeResolver;
     $this->scope = $scope;
     parent::__construct($resource);
 }
Beispiel #22
0
 public function testPrepareDataForUpdate()
 {
     $adapterInterfaceMock = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $context = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Framework\\Model\\Context');
     $registryMock = $this->getMock('\\Magento\\Framework\\Registry', [], [], '', false);
     $resourceMock = $this->getMock('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', ['_construct', '_getReadAdapter', '_getWriteAdapter', '__wakeup', 'getIdFieldName'], [], '', false);
     $adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $resourceMock->expects($this->any())->method('_getWriteAdapter')->will($this->returnValue($adapterMock));
     $resourceCollectionMock = $this->getMockBuilder('Magento\\Framework\\Data\\Collection\\AbstractDb')->disableOriginalConstructor()->getMockForAbstractClass();
     $abstractModelMock = $this->getMockForAbstractClass('Magento\\Framework\\Model\\AbstractModel', [$context, $registryMock, $resourceMock, $resourceCollectionMock]);
     $data = 'tableName';
     $this->_resourcesMock->expects($this->any())->method('getConnection')->will($this->returnValue($adapterInterfaceMock));
     $this->_resourcesMock->expects($this->any())->method('getTableName')->with($data)->will($this->returnValue('tableName'));
     $this->_resourcesMock->expects($this->any())->method('_getWriteAdapter')->will($this->returnValue($adapterInterfaceMock));
     $mainTableReflection = new \ReflectionProperty('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', '_mainTable');
     $mainTableReflection->setAccessible(true);
     $mainTableReflection->setValue($this->_model, 'tableName');
     $idFieldNameReflection = new \ReflectionProperty('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', '_idFieldName');
     $idFieldNameReflection->setAccessible(true);
     $idFieldNameReflection->setValue($this->_model, 'idFieldName');
     $adapterInterfaceMock->expects($this->any())->method('save')->with('tableName', 'idFieldName');
     $adapterInterfaceMock->expects($this->any())->method('quoteInto')->will($this->returnValue('idFieldName'));
     $abstractModelMock->setIdFieldName('id');
     $abstractModelMock->setData(['id' => 12345, 'name' => 'Test Name', 'value' => 'Test Value']);
     $abstractModelMock->afterLoad();
     $this->assertEquals($abstractModelMock->getData(), $abstractModelMock->getStoredData());
     $newData = ['value' => 'Test Value New'];
     $this->_model->expects($this->once())->method('_prepareDataForTable')->will($this->returnValue($newData));
     $abstractModelMock->addData($newData);
     $this->assertNotEquals($abstractModelMock->getData(), $abstractModelMock->getStoredData());
     $abstractModelMock->isObjectNew(false);
     $adapterInterfaceMock->expects($this->once())->method('update')->with('tableName', $newData, 'idFieldName');
     $this->_model->save($abstractModelMock);
 }
Beispiel #23
0
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\Filter\FilterManager $filter
  * @param Helper $resourceHelper
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Filter\FilterManager $filter, \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper)
 {
     $this->_eventManager = $eventManager;
     $this->filter = $filter;
     $this->_resourceHelper = $resourceHelper;
     parent::__construct($resource);
 }
 /**
  * Load an object using 'url_key' field if there's no field specified and value is not numeric
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @param mixed $value
  * @param string $field
  * @return $this
  */
 public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
 {
     if (!is_numeric($value) && is_null($field)) {
         $field = 'url_key';
     }
     return parent::load($object, $value, $field);
 }
Beispiel #25
0
 /**
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param \Magento\Catalog\Helper\Data $catalogData
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $configuration
  * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $configuration, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, $resourcePrefix = null)
 {
     $this->_catalogData = $catalogData;
     $this->_configuration = $configuration;
     $this->_currencyFactory = $currencyFactory;
     $this->_storeManager = $storeManager;
     parent::__construct($context, $resourcePrefix);
 }
Beispiel #26
0
 /**
  * @param int $isFilter
  * @param string $useAggregatedData
  * @param string $mainTable
  * @dataProvider salesDataProvider
  * @return void
  */
 public function testCalculateSales($isFilter, $useAggregatedData, $mainTable)
 {
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with('sales/dashboard/use_aggregated_data', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->willReturn($useAggregatedData);
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock);
     $this->resourceMock->expects($this->at(0))->method('getTable')->with($mainTable);
     $this->collection->calculateSales($isFilter);
 }
Beispiel #27
0
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Framework\Acl\Builder $aclBuilder
  * @param \Magento\Framework\Logger $logger
  * @param \Magento\Framework\Acl\RootResource $rootResource
  * @param \Magento\Framework\Acl\CacheInterface $aclCache
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Acl\Builder $aclBuilder, \Magento\Framework\Logger $logger, \Magento\Framework\Acl\RootResource $rootResource, \Magento\Framework\Acl\CacheInterface $aclCache)
 {
     $this->_aclBuilder = $aclBuilder;
     parent::__construct($resource);
     $this->_rootResource = $rootResource;
     $this->_aclCache = $aclCache;
     $this->_logger = $logger;
 }
Beispiel #28
0
 /**
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\DateTime $dateTime
  * @param StockConfigurationInterface $stockConfiguration
  * @param StoreManagerInterface $storeManager
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\DateTime $dateTime, StockConfigurationInterface $stockConfiguration, StoreManagerInterface $storeManager, $resourcePrefix = null)
 {
     parent::__construct($context, $resourcePrefix);
     $this->_scopeConfig = $scopeConfig;
     $this->dateTime = $dateTime;
     $this->stockConfiguration = $stockConfiguration;
     $this->storeManager = $storeManager;
 }
Beispiel #29
0
 /**
  * Prepare wishlist load select query
  *
  * @param string $field
  * @param mixed $value
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Zend_Db_Select
  */
 protected function _getLoadSelect($field, $value, $object)
 {
     $select = parent::_getLoadSelect($field, $value, $object);
     if ($field == $this->_customerIdFieldName) {
         $select->order('wishlist_id ' . \Zend_Db_Select::SQL_ASC)->limit(1);
     }
     return $select;
 }
Beispiel #30
0
 /**
  * {@inheritdoc}
  */
 protected function prepareDataForUpdate($object)
 {
     $data = parent::prepareDataForUpdate($object);
     if (isset($data['updated_at'])) {
         unset($data['updated_at']);
     }
     return $data;
 }