Example #1
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The model is empty
  */
 public function testExceptionEmptyEntity()
 {
     $entity = $this->getMock('Magento\\Cms\\Model\\Block', [], [], '', false);
     $entityId = 0;
     $entity->expects($this->exactly(1))->method('getId')->will($this->returnValue($entityId));
     $this->_codeModelMock->expects($this->never())->method('loadByEntityIdAndType');
     $this->assertEquals($this->_codeModelMock, $this->_helper->getCodeObjectByEntity($entity, \Magento\GoogleOptimizer\Model\Code::ENTITY_TYPE_PAGE));
 }
 /**
  * Get google experiment code model
  *
  * @return \Magento\GoogleOptimizer\Model\Code|null
  * @throws \RuntimeException
  */
 protected function _getGoogleExperiment()
 {
     $category = $this->_getCategory();
     if ($category->getId()) {
         return $this->_codeHelper->getCodeObjectByEntity($category);
     }
     return null;
 }
 /**
  * Get Code model
  *
  * @return \Magento\GoogleOptimizer\Model\Code|null
  */
 protected function getCodeModel()
 {
     if ($this->locator->getProduct()->getId()) {
         return $this->codeHelper->getCodeObjectByEntity($this->locator->getProduct());
     }
     return null;
 }
Example #4
0
 /**
  * Get google experiment code model
  *
  * @return \Magento\GoogleOptimizer\Model\Code
  * @throws \RuntimeException
  */
 protected function _getGoogleExperiment()
 {
     return $this->_codeHelper->getCodeObjectByEntity($this->_getEntity());
 }