Esempio n. 1
0
 protected function processAttributeGetter($dbAttributes)
 {
     $select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->connection->expects($this->once())->method('select')->will($this->returnValue($select));
     $select->expects($this->once())->method('from')->will($this->returnSelf());
     $select->expects($this->once())->method('where')->will($this->returnSelf());
     $this->connection->expects($this->once())->method('fetchAll')->with($select)->will($this->returnValue($dbAttributes));
     $this->link->expects($this->any())->method('getAttributeTypeTable')->will($this->returnValue('table_name'));
 }
Esempio n. 2
0
 /**
  * @return array
  */
 public function getAttributes()
 {
     if (empty($this->attributes)) {
         $select = $this->connection->select()->from($this->productLink->getTable('catalog_product_link_attribute'), ['id' => 'product_link_attribute_id', 'code' => 'product_link_attribute_code', 'type' => 'data_type'])->where('link_type_id = ?', $this->getLinkTypeId());
         foreach ($this->connection->fetchAll($select) as $row) {
             $this->attributes[$row['code']] = ['id' => $row['id'], 'table' => $this->productLink->getAttributeTypeTable($row['type'])];
         }
     }
     return $this->attributes;
 }
Esempio n. 3
0
 public function testGetParentIdsByChild()
 {
     $childId = 234;
     $typeId = 4;
     $fetchedData = [['product_id' => 55], ['product_id' => 66]];
     $result = [55, 66];
     // method flow
     $this->prepareReadAdapter();
     $this->dbSelect->expects($this->once())->method('from')->will($this->returnValue($this->dbSelect));
     $this->dbSelect->expects($this->any())->method('where')->will($this->returnValue($this->dbSelect));
     $this->readAdapter->expects($this->once())->method('fetchAll')->with($this->dbSelect)->will($this->returnValue($fetchedData));
     $this->assertEquals($result, $this->model->getParentIdsByChild($childId, $typeId));
 }