public function testToHtmlWithId() { $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['id', null, 1], ['store_id', null, 0]])); $this->queue->expects($this->once())->method('load')->will($this->returnSelf()); $this->template->expects($this->any())->method('isPlain')->will($this->returnValue(true)); /** @var \Magento\Store\Model\Store $store */ $this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue(null)); $store = $this->getMock('Magento\\Store\\Model\\Store', ['getId'], [], '', false); $this->storeManager->expects($this->once())->method('getStores')->will($this->returnValue([0 => $store])); $result = $this->preview->toHtml(); $this->assertEquals('<pre></pre>', $result); }
/** * Updates data when subscriber received * * @param \Magento\Newsletter\Model\Subscriber $subscriber * @param \Magento\Newsletter\Model\Queue $queue * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Magento\Newsletter\Model\Queue $queue) { $this->connection->beginTransaction(); try { $data['letter_sent_at'] = $this->_date->gmtDate(); $this->connection->update($this->_subscriberLinkTable, $data, ['subscriber_id = ?' => $subscriber->getId(), 'queue_id = ?' => $queue->getId()]); $this->connection->commit(); } catch (\Exception $e) { $this->connection->rollBack(); throw new \Magento\Framework\Exception\LocalizedException(__('We cannot mark as received subscriber.')); } return $this; }
public function testGetStores() { $stores = ['store']; $this->resource->expects($this->once())->method('getStores')->willReturn($stores); $this->assertEquals($stores, $this->queue->getStores()); }
/** * Add Queue Data * * @param \Magento\Newsletter\Model\Queue $queue * @return $this */ public function addQueueData(\Magento\Newsletter\Model\Queue $queue) { $this->setQueueId($queue->getId()); return $this; }
/** * Set loading mode subscribers by queue * * @param ModelQueue $queue * @return $this */ public function useQueue(ModelQueue $queue) { $this->getSelect()->join(array('link' => $this->_queueLinkTable), "link.subscriber_id = main_table.subscriber_id", array())->where("link.queue_id = ? ", $queue->getId()); $this->_queueJoinedFlag = true; return $this; }
/** * Returns queue linked stores * * @param ModelQueue $queue * @return array */ public function getStores(ModelQueue $queue) { $adapter = $this->_getReadAdapter(); $select = $adapter->select()->from($this->getTable('newsletter_queue_store_link'), 'store_id')->where('queue_id = :queue_id'); if (!($result = $adapter->fetchCol($select, array('queue_id' => $queue->getId())))) { $result = array(); } return $result; }
/** * Returns queue linked stores * * @param ModelQueue $queue * @return array */ public function getStores(ModelQueue $queue) { $connection = $this->getConnection(); $select = $connection->select()->from($this->getTable('newsletter_queue_store_link'), 'store_id')->where('queue_id = :queue_id'); if (!($result = $connection->fetchCol($select, ['queue_id' => $queue->getId()]))) { $result = []; } return $result; }