_paymentData = $this->getMockBuilder( \Magento\Payment\Helper\Data::class )->disableOriginalConstructor()->setMethods([])->getMock(); $this->_model = new Allmethods($this->_paymentData); } public function testToOptionArray() { $expectedArray = ['key' => 'value']; $this->_paymentData->expects($this->once()) ->method('getPaymentMethodList') ->with(true, true, true) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $this->_model->toOptionArray()); } }