Example #1
0
 protected function setUp()
 {
     $this->ratingOptionCollection = $this->getMock('\\Magento\\Review\\Model\\Resource\\Rating\\Option\\Collection', [], [], '', false);
     $this->element = $this->getMock('\\Magento\\Framework\\Data\\Form\\Element\\Text', ['setValue', 'setIsChecked'], [], '', false);
     $this->session = $this->getMock('\\Magento\\Framework\\Session\\Generic', ['getRatingData', 'setRatingData'], [], '', false);
     $this->rating = $this->getMock('\\Magento\\Review\\Model\\Rating', ['getId', 'getRatingCodes'], [], '', false);
     $this->optionRating = $this->getMock('\\Magento\\Review\\Model\\Rating\\Option', [], [], '', false);
     $this->store = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     $this->form = $this->getMock('\\Magento\\Framework\\Data\\Form', [], [], '', false);
     $this->directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->registry = $this->getMock('\\Magento\\Framework\\Registry');
     $this->formFactory = $this->getMock('\\Magento\\Framework\\Data\\FormFactory', [], [], '', false);
     $this->optionFactory = $this->getMock('\\Magento\\Review\\Model\\Rating\\OptionFactory', ['create'], [], '', false);
     $this->systemStore = $this->getMock('\\Magento\\Store\\Model\\System\\Store', [], [], '', false);
     $this->viewFileSystem = $this->getMock('\\Magento\\Framework\\View\\FileSystem', [], [], '', false);
     $this->fileSystem = $this->getMock('\\Magento\\Framework\\Filesystem', ['getDirectoryRead'], [], '', false);
     $this->rating->expects($this->any())->method('getId')->will($this->returnValue('1'));
     $this->ratingOptionCollection->expects($this->any())->method('addRatingFilter')->will($this->returnSelf());
     $this->ratingOptionCollection->expects($this->any())->method('load')->will($this->returnSelf());
     $this->ratingOptionCollection->expects($this->any())->method('getItems')->will($this->returnValue([$this->optionRating]));
     $this->optionRating->expects($this->any())->method('getResourceCollection')->will($this->returnValue($this->ratingOptionCollection));
     $this->store->expects($this->any())->method('getId')->will($this->returnValue('0'));
     $this->store->expects($this->any())->method('getName')->will($this->returnValue('store_name'));
     $this->element->expects($this->any())->method('setValue')->will($this->returnSelf());
     $this->element->expects($this->any())->method('setIsChecked')->will($this->returnSelf());
     $this->form->expects($this->any())->method('setForm')->will($this->returnSelf());
     $this->form->expects($this->any())->method('addFieldset')->will($this->returnSelf());
     $this->form->expects($this->any())->method('addField')->will($this->returnSelf());
     $this->form->expects($this->any())->method('setRenderer')->will($this->returnSelf());
     $this->optionFactory->expects($this->any())->method('create')->will($this->returnValue($this->optionRating));
     $this->systemStore->expects($this->any())->method('getStoreCollection')->will($this->returnValue(['0' => $this->store]));
     $this->formFactory->expects($this->any())->method('create')->will($this->returnValue($this->form));
     $this->viewFileSystem->expects($this->any())->method('getTemplateFileName')->will($this->returnValue('template_file_name.html'));
     $this->fileSystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->directoryReadInterface));
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->block = $objectManagerHelper->getObject('Magento\\Review\\Block\\Adminhtml\\Rating\\Edit\\Tab\\Form', ['registry' => $this->registry, 'formFactory' => $this->formFactory, 'optionFactory' => $this->optionFactory, 'systemStore' => $this->systemStore, 'session' => $this->session, 'viewFileSystem' => $this->viewFileSystem, 'filesystem' => $this->fileSystem]);
 }
Example #2
0
 /**
  * Aggregate options
  *
  * @param \Magento\Review\Model\Rating\Option $option
  * @return void
  */
 public function aggregate($option)
 {
     $vote = $this->_ratingOptionVoteF->create()->load($option->getVoteId());
     $this->aggregateEntityByRatingId($vote->getRatingId(), $vote->getEntityPkValue());
 }
Example #3
0
 /**
  * Indicator of whether or not a rating is selected
  *
  * @param Option $option
  * @param \Magento\Review\Model\Rating $rating
  * @return bool
  */
 public function isSelected($option, $rating)
 {
     if ($this->getIsIndependentMode()) {
         $ratings = $this->getRequest()->getParam('ratings');
         if (isset($ratings[$option->getRatingId()])) {
             return $option->getId() == $ratings[$option->getRatingId()];
         } elseif (!$this->_voteCollection) {
             return false;
         }
     }
     if ($this->_voteCollection) {
         foreach ($this->_voteCollection as $vote) {
             if ($option->getId() == $vote->getOptionId()) {
                 return true;
             }
         }
     }
     return false;
 }