protected function _prepareAddFilterStubs() { $entityInfo = []; $entityInfo['entity_id_field'] = 'entity_id'; $entityInfo['rule_id_field'] = 'rule_id'; $entityInfo['associations_table'] = 'assoc_table'; $connection = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface'); $select = $this->getMock('\\Magento\\Framework\\DB\\Select', [], [], '', false); $collectionSelect = $this->getMock('\\Magento\\Framework\\DB\\Select', [], [], '', false); $connection->expects($this->any())->method('select')->will($this->returnValue($select)); $select->expects($this->any())->method('from')->will($this->returnSelf()); $select->expects($this->any())->method('where')->will($this->returnSelf()); $collectionSelect->expects($this->once())->method('exists'); $this->abstractCollection->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); $this->_db->expects($this->any())->method('getTable')->will($this->returnArgument(0)); $this->abstractCollection->expects($this->any())->method('getSelect')->will($this->returnValue($collectionSelect)); $this->abstractCollection->expects($this->any())->method('_getAssociatedEntityInfo')->will($this->returnValue($entityInfo)); }