public function setUp() { $this->_connectionFactory = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Type\\Db\\ConnectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->_config = $this->getMockBuilder('Magento\\Framework\\App\\Resource\\ConfigInterface')->disableOriginalConstructor()->setMethods(['getConnectionName'])->getMock(); $this->_config->expects($this->any())->method('getConnectionName')->with(self::RESOURCE_NAME)->will($this->returnValue(self::CONNECTION_NAME)); $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false); $this->deploymentConfig->expects($this->any())->method('get')->will($this->returnValue(['default' => ['host' => 'localhost', 'dbname' => 'magento', 'username' => 'username'], self::CONNECTION_NAME => ['host' => 'localhost', 'dbname' => 'magento', 'username' => 'username']])); $this->connection = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Adapter\\AdapterInterface'); $this->connection->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); $this->resource = new Resource($this->_config, $this->_connectionFactory, $this->deploymentConfig, self::TABLE_PREFIX); }