public function testPrepareProductRecurringPaymentOptions() { $payment = $this->getMock('Magento\\Framework\\Object', array('setStory', 'importBuyRequest', 'importProduct', 'exportStartDatetime', 'exportScheduleInfo', 'getFieldLabel'), array(), '', false); $payment->expects($this->once())->method('exportStartDatetime')->will($this->returnValue('date')); $payment->expects($this->any())->method('setStore')->will($this->returnValue($payment)); $payment->expects($this->once())->method('importBuyRequest')->will($this->returnValue($payment)); $payment->expects($this->once())->method('exportScheduleInfo')->will($this->returnValue(array(new \Magento\Framework\Object(array('title' => 'Title', 'schedule' => 'schedule'))))); $this->_fieldsBlock->expects($this->once())->method('getFieldLabel')->will($this->returnValue('Field Label')); $this->_recurringPaymentFactory->expects($this->once())->method('create')->will($this->returnValue($payment)); $product = $this->getMock('Magento\\Framework\\Object', array('getIsRecurring', 'addCustomOption'), array(), '', false); $product->expects($this->once())->method('getIsRecurring')->will($this->returnValue(true)); $infoOptions = array(array('label' => 'Field Label', 'value' => 'date'), array('label' => 'Title', 'value' => 'schedule')); $product->expects($this->at(2))->method('addCustomOption')->with('additional_options', serialize($infoOptions)); $this->_event->expects($this->any())->method('getProduct')->will($this->returnValue($product)); $this->_testModel->prepareProductRecurringPaymentOptions($this->_observer); }