示例#1
0
 public function testGetLabelWithoutCustomText()
 {
     $category = 'Some text';
     $id = 1;
     $idPath = 'id/' . $id;
     $store = 1;
     $this->block->setData('id_path', $idPath);
     $this->storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store));
     $this->entityResource->expects($this->once())->method('getAttributeRawValue')->with($id, 'name', $store)->will($this->returnValue($category));
     $this->assertEquals($category, $this->block->getLabel());
 }
示例#2
0
 /**
  * Prepare label using passed text as parameter.
  * If anchor text was not specified get entity name from DB.
  *
  * @return string
  */
 public function getLabel()
 {
     if (!$this->_anchorText) {
         if ($this->getData('anchor_text')) {
             $this->_anchorText = $this->getData('anchor_text');
         } elseif ($this->_entityResource) {
             $idPath = explode('/', $this->_getData('id_path'));
             if (isset($idPath[1])) {
                 $id = $idPath[1];
                 if ($id) {
                     $this->_anchorText = $this->_entityResource->getAttributeRawValue($id, 'name', $this->_storeManager->getStore());
                 }
             }
         }
     }
     return $this->_anchorText;
 }