public function testExecuteAgreementStatusDoesNotAllowToCancel() { $this->_agreement->expects($this->once())->method('canCancel')->will($this->returnValue(false)); $this->_agreement->expects($this->never())->method('cancel'); $this->_session->expects($this->once())->method('getCustomerId')->will($this->returnValue(871)); $this->_messageManager->expects($this->never())->method('addNoticeMessage'); $this->_messageManager->expects($this->never())->method('addErrorMessage'); $this->_registry->expects($this->once())->method('register')->with('current_billing_agreement', $this->identicalTo($this->_agreement)); $this->_controller->execute(); }
/** * Add columns to grid * * @return $this */ protected function _prepareColumns() { $this->addColumn('agreement_id', array('header' => __('ID'), 'index' => 'agreement_id', 'type' => 'text', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id')); $this->addColumn('customer_email', array('header' => __('Email'), 'index' => 'customer_email', 'type' => 'text', 'header_css_class' => 'col-mail', 'column_css_class' => 'col-mail')); $this->addColumn('customer_firstname', array('header' => __('First Name'), 'index' => 'customer_firstname', 'type' => 'text', 'escape' => true, 'header_css_class' => 'col-name', 'column_css_class' => 'col-name')); $this->addColumn('customer_lastname', array('header' => __('Last Name'), 'index' => 'customer_lastname', 'type' => 'text', 'escape' => true, 'header_css_class' => 'col-last-name', 'column_css_class' => 'col-last-name')); $this->addColumn('reference_id', array('header' => __('Reference ID'), 'index' => 'reference_id', 'type' => 'text', 'header_css_class' => 'col-reference', 'column_css_class' => 'col-reference')); $this->addColumn('status', array('header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_agreementModel->getStatusesArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status')); $this->addColumn('created_at', array('header' => __('Created'), 'index' => 'created_at', 'type' => 'datetime', 'align' => 'center', 'default' => __('N/A'), 'html_decorators' => array('nobr'), 'header_css_class' => 'col-period', 'column_css_class' => 'col-period')); $this->addColumn('updated_at', array('header' => __('Updated'), 'index' => 'updated_at', 'type' => 'datetime', 'align' => 'center', 'default' => __('N/A'), 'html_decorators' => array('nobr'), 'header_css_class' => 'col-period', 'column_css_class' => 'col-period')); return parent::_prepareColumns(); }
/** * Retrieve item value by key * * @param \Magento\Framework\DataObject|\Magento\Paypal\Model\Billing\Agreement $item * @param string $key * @return string */ public function getItemValue(\Magento\Paypal\Model\Billing\Agreement $item, $key) { switch ($key) { case 'created_at': case 'updated_at': $value = $item->getData($key) ? $this->formatDate($item->getData($key), \IntlDateFormatter::SHORT, true) : __('N/A'); break; case 'edit_url': $value = $this->getUrl('paypal/billing_agreement/view', ['agreement' => $item->getAgreementId()]); break; case 'payment_method_label': $label = $item->getAgreementLabel(); $value = $label ? $label : __('N/A'); break; case 'status': $value = $item->getStatusLabel(); break; default: $value = $item->getData($key) ? $item->getData($key) : __('N/A'); break; } return $this->escapeHtml($value); }
/** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param \Adyen\Payment\Helper\Data $adyenHelper * @param array $data */ public function __construct(\Adyen\Payment\Helper\Data $adyenHelper, \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Payment\Helper\Data $paymentData, \Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementFactory, \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = []) { parent::__construct($context, $registry, $paymentData, $billingAgreementFactory, $dateFactory, $resource, $resourceCollection, $data); $this->_adyenHelper = $adyenHelper; }