diff --git a/payment/config/schema/payment.schema.yml b/payment/config/schema/payment.schema.yml index a8a75bd..de82b52 100644 --- a/payment/config/schema/payment.schema.yml +++ b/payment/config/schema/payment.schema.yml @@ -23,9 +23,15 @@ payment.payment_method_configuration.*: capture: label: Capture type: boolean - execute_status_id: + capture_status_id: label: Capture payment status type: string + refund: + label: Refund + type: boolean + refund_status_id: + label: Refund payment status + type: string # This is for payment method entities that use a plugin that extends # \Drupal\payment\Plugin\Payment\MethodConfiguration\PaymentMethodConfigurationBase message_text: diff --git a/payment/src/Entity/Payment.php b/payment/src/Entity/Payment.php index bb159a9..ec96854 100644 --- a/payment/src/Entity/Payment.php +++ b/payment/src/Entity/Payment.php @@ -32,7 +32,8 @@ use Drupal\user\UserInterface; * "delete" = "Drupal\payment\Entity\Payment\PaymentDeleteForm", * "edit" = "Drupal\payment\Entity\Payment\PaymentEditForm", * "update_status" = "Drupal\payment\Entity\Payment\PaymentStatusForm", - * "capture" = "Drupal\payment\Entity\Payment\PaymentCaptureForm" + * "capture" = "Drupal\payment\Entity\Payment\PaymentCaptureForm", + * "refund" = "Drupal\payment\Entity\Payment\PaymentRefundForm" * }, * "list_builder" = "Drupal\payment\Entity\Payment\PaymentListBuilder", * "view_builder" = "Drupal\payment\Entity\Payment\PaymentViewBuilder", diff --git a/payment/src/Plugin/Payment/Method/Basic.php b/payment/src/Plugin/Payment/Method/Basic.php index aee7706..96d9f60 100644 --- a/payment/src/Plugin/Payment/Method/Basic.php +++ b/payment/src/Plugin/Payment/Method/Basic.php @@ -10,6 +10,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Utility\Token; +use Drupal\payment\Entity\PaymentInterface; use Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -25,6 +26,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; * - capture: (boolean) Whether or not payment capture is supported. * - capture_status_id: (string) The ID of the payment status plugin to set at * payment capture. + * - refund: (boolean) Whether or not payment refunds are supported. + * - refund_status_id: (string) The ID of the payment status plugin to set at + * payment refund. * * @PaymentMethod( * deriver = "Drupal\payment\Plugin\Payment\Method\BasicDeriver", @@ -32,7 +36,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; * operations_provider = "\Drupal\payment\Plugin\Payment\Method\BasicOperationsProvider", * ) */ -class Basic extends PaymentMethodBase implements ContainerFactoryPluginInterface, PaymentMethodCapturePaymentInterface { +class Basic extends PaymentMethodBase implements ContainerFactoryPluginInterface, PaymentMethodCapturePaymentInterface, PaymentMethodRefundPaymentInterface, PaymentMethodUpdatePaymentStatusInterface { /** * The payment status manager. @@ -119,6 +123,26 @@ class Basic extends PaymentMethodBase implements ContainerFactoryPluginInterface } /** + * Gets the status to set on payment refund. + * + * @return string + * The plugin ID of the payment status to set. + */ + public function getRefundStatusId() { + return $this->pluginDefinition['refund_status_id']; + } + + /** + * Gets whether or not capture is supported. + * + * @param bool + * Whether or not to support capture. + */ + public function getRefund() { + return $this->pluginDefinition['refund']; + } + + /** * {@inheritdoc} */ protected function doExecutePayment() { @@ -139,20 +163,36 @@ class Basic extends PaymentMethodBase implements ContainerFactoryPluginInterface * {@inheritdoc} */ public function doCapturePaymentAccess(AccountInterface $account) { - return $this->getCapture() && $this->getPayment()->getStatus()->getPluginId() != $this->getCaptureStatusId(); + return $this->getCapture() && $this->getPayment()->getStatus()->getPluginId() == $this->getExecuteStatusId(); } /** * {@inheritdoc} */ public function doRefundPayment() { + $this->getPayment()->setStatus($this->paymentStatusManager->createInstance($this->getRefundStatusId())); + $this->getPayment()->save(); } /** * {@inheritdoc} */ public function doRefundPaymentAccess(AccountInterface $account) { + return $this->getRefund() && $this->getPayment()->getStatus()->getPluginId() == $this->getCaptureStatusId(); + } + + /** + * {@inheritdoc} + */ + public function updatePaymentStatusAccess(AccountInterface $account) { return FALSE; } + /** + * {@inheritdoc} + */ + public function getSettablePaymentStatuses(AccountInterface $account, PaymentInterface $payment) { + return array(); + } + } diff --git a/payment/src/Plugin/Payment/Method/BasicDeriver.php b/payment/src/Plugin/Payment/Method/BasicDeriver.php index 805c719..85ff2ab 100644 --- a/payment/src/Plugin/Payment/Method/BasicDeriver.php +++ b/payment/src/Plugin/Payment/Method/BasicDeriver.php @@ -67,9 +67,11 @@ class BasicDeriver extends DeriverBase implements ContainerDeriverInterface { 'label' => $configuration_plugin->getBrandLabel() ? $configuration_plugin->getBrandLabel() : $payment_method->label(), 'message_text' => $configuration_plugin->getMessageText(), 'message_text_format' => $configuration_plugin->getMessageTextFormat(), - 'execute_status_id' => $configuration_plugin->getExecuteStatusId(), - 'capture' => $configuration_plugin->getCapture(), - 'capture_status_id' => $configuration_plugin->getCaptureStatusId(), + 'execute_status_id' => $configuration_plugin->getExecuteStatusId(), + 'capture' => $configuration_plugin->getCapture(), + 'capture_status_id' => $configuration_plugin->getCaptureStatusId(), + 'refund' => $configuration_plugin->getRefund(), + 'refund_status_id' => $configuration_plugin->getRefundStatusId(), ) + $base_plugin_definition; } } diff --git a/payment/src/Plugin/Payment/Method/PaymentMethodBase.php b/payment/src/Plugin/Payment/Method/PaymentMethodBase.php index 99cd531..6a4f14b 100644 --- a/payment/src/Plugin/Payment/Method/PaymentMethodBase.php +++ b/payment/src/Plugin/Payment/Method/PaymentMethodBase.php @@ -237,7 +237,7 @@ abstract class PaymentMethodBase extends PluginBase implements AccessInterface, throw new \LogicException('Trying to check access for a non-existing payment. A payment must be set trough self::setPayment() first.'); } - return $this->getPayment()->access('capture') && $this->doCapturePaymentAccess($account); + return $this->doCapturePaymentAccess($account); } /** @@ -276,7 +276,7 @@ abstract class PaymentMethodBase extends PluginBase implements AccessInterface, throw new \LogicException('Trying to check access for a non-existing payment. A payment must be set trough self::setPayment() first.'); } - return $this->getPayment()->access('refund') && $this->doRefundPaymentAccess($account); + return $this->doRefundPaymentAccess($account); } /** diff --git a/payment/src/Plugin/Payment/MethodConfiguration/Basic.php b/payment/src/Plugin/Payment/MethodConfiguration/Basic.php index 2972dfa..4d2325b 100644 --- a/payment/src/Plugin/Payment/MethodConfiguration/Basic.php +++ b/payment/src/Plugin/Payment/MethodConfiguration/Basic.php @@ -233,7 +233,6 @@ class Basic extends PaymentMethodConfigurationBase implements ContainerFactoryPl ), ), '#type' => 'vertical_tabs', - '#title' => $this->t('Workflow'), ); $elements['execute'] = array( '#group' => 'workflow', @@ -315,12 +314,14 @@ class Basic extends PaymentMethodConfigurationBase implements ContainerFactoryPl */ public function submitConfigurationForm(array &$form, array &$form_state) { parent::submitConfigurationForm($form, $form_state); - $parents = $form['brand_label']['#parents']; + $parents = $form['plugin_form']['brand_label']['#parents']; array_pop($parents); $values = NestedArray::getValue($form_state['values'], $parents); $this->setExecuteStatusId($values['execute_status_id']); $this->setCapture($values['capture']); - $this->setCaptureStatusId($values['capture_status_id_wrapper']['capture_status_id']); + $this->setCaptureStatusId($values['capture_status_id']); + $this->setRefund($values['refund']); + $this->setRefundStatusId($values['refund_status_id']); $this->setBrandLabel($values['brand_label']); } diff --git a/payment/src/Plugin/Payment/Status/Refunded.php b/payment/src/Plugin/Payment/Status/Refunded.php index 5434d65..16ce1f6 100644 --- a/payment/src/Plugin/Payment/Status/Refunded.php +++ b/payment/src/Plugin/Payment/Status/Refunded.php @@ -15,5 +15,5 @@ namespace Drupal\payment\Plugin\Payment\Status; * parent_id = "payment_no_money_transferred" * ) */ -class Failed extends PaymentStatusBase { +class Refunded extends PaymentStatusBase { } diff --git a/payment/tests/src/Plugin/Payment/Method/BasicDeriverUnitTest.php b/payment/tests/src/Plugin/Payment/Method/BasicDeriverUnitTest.php index 83facc3..24c3a42 100644 --- a/payment/tests/src/Plugin/Payment/Method/BasicDeriverUnitTest.php +++ b/payment/tests/src/Plugin/Payment/Method/BasicDeriverUnitTest.php @@ -96,6 +96,8 @@ class BasicDeriverUnitTest extends UnitTestCase { $execute_status_id = $this->randomName(); $capture = TRUE; $capture_status_id = $this->randomName(); + $refund = TRUE; + $refund_status_id = $this->randomName(); $payment_method_enabled_basic = $this->getMock('\Drupal\payment\Entity\PaymentMethodConfigurationInterface'); $payment_method_enabled_basic->expects($this->any()) @@ -113,6 +115,8 @@ class BasicDeriverUnitTest extends UnitTestCase { 'execute_status_id' => $execute_status_id, 'capture' => $capture, 'capture_status_id' => $capture_status_id, + 'refund' => $refund, + 'refund_status_id' => $refund_status_id, ))); $payment_method_enabled_basic->expects($this->any()) ->method('getPluginId') @@ -134,6 +138,8 @@ class BasicDeriverUnitTest extends UnitTestCase { 'execute_status_id' => $execute_status_id, 'capture' => $capture, 'capture_status_id' => $capture_status_id, + 'refund' => $refund, + 'refund_status_id' => $refund_status_id, ))); $payment_method_disabled_basic->expects($this->any()) ->method('getPluginId') @@ -172,6 +178,12 @@ class BasicDeriverUnitTest extends UnitTestCase { $payment_method_plugin->expects($this->any()) ->method('getCapture') ->will($this->returnValue($capture)); + $payment_method_plugin->expects($this->any()) + ->method('getRefundStatusId') + ->will($this->returnValue($refund_status_id)); + $payment_method_plugin->expects($this->any()) + ->method('getRefund') + ->will($this->returnValue($refund)); $this->paymentMethodConfigurationManager->expects($this->any()) ->method('createInstance') diff --git a/payment/tests/src/Plugin/Payment/Method/BasicUnitTest.php b/payment/tests/src/Plugin/Payment/Method/BasicUnitTest.php index a16d3fa..6ec5886 100644 --- a/payment/tests/src/Plugin/Payment/Method/BasicUnitTest.php +++ b/payment/tests/src/Plugin/Payment/Method/BasicUnitTest.php @@ -53,6 +53,8 @@ class BasicUnitTest extends PaymentMethodBaseUnitTestBase { 'execute_status_id' => $this->randomName(), 'capture' => TRUE, 'capture_status_id' => $this->randomName(), + 'refund' => TRUE, + 'refund_status_id' => $this->randomName(), ); $this->paymentStatusManager = $this->getMock('\Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface'); @@ -108,6 +110,20 @@ class BasicUnitTest extends PaymentMethodBaseUnitTestBase { } /** + * @covers ::getRefundStatusId + */ + public function testGetRefundStatusId() { + $this->assertSame($this->pluginDefinition['refund_status_id'], $this->paymentMethod->getRefundStatusId()); + } + + /** + * @covers ::getRefund + */ + public function testGetRefund() { + $this->assertSame($this->pluginDefinition['refund'], $this->paymentMethod->getRefund()); + } + + /** * @covers ::doExecutePayment */ public function testDoExecutePayment() { @@ -175,14 +191,20 @@ class BasicUnitTest extends PaymentMethodBaseUnitTestBase { * * @dataProvider providerDoCapturePaymentAccess */ - public function testDoCapturePaymentAccess($expected, $capture, $current_status_id, $capture_status_id) { + public function testDoCapturePaymentAccess($expected, $capture, $current_status_id, $execute_status_id, $capture_status_id) { + $this->pluginDefinition['execute_status_id'] = $execute_status_id; $this->pluginDefinition['capture'] = $capture; $this->pluginDefinition['capture_status_id'] = $capture_status_id; $this->paymentMethod = new Basic(array(), '', $this->pluginDefinition, $this->moduleHandler, $this->eventDispatcher, $this->token, $this->paymentStatusManager); - $payment_status = $this->getMock('\Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface'); - $payment_status->expects($this->any()) + $capture_payment_status = $this->getMock('\Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface'); + $capture_payment_status->expects($this->any()) + ->method('getPluginId') + ->will($this->returnValue($current_status_id)); + + $capture_payment_status = $this->getMock('\Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface'); + $capture_payment_status->expects($this->any()) ->method('getPluginId') ->will($this->returnValue($current_status_id)); @@ -191,7 +213,7 @@ class BasicUnitTest extends PaymentMethodBaseUnitTestBase { ->getMock(); $payment->expects($this->any()) ->method('getStatus') - ->will($this->returnValue($payment_status)); + ->will($this->returnValue($capture_payment_status)); $this->paymentMethod->setPayment($payment); @@ -209,14 +231,113 @@ class BasicUnitTest extends PaymentMethodBaseUnitTestBase { public function providerDoCapturePaymentAccess() { $status_id_a = $this->randomName(); $status_id_b = $this->randomName(); + $status_id_c = $this->randomName(); + return array( + array(TRUE, TRUE, $status_id_a, $status_id_a, $status_id_b), + array(FALSE, TRUE, $status_id_a, $status_id_b, $status_id_c), + array(FALSE, FALSE, $status_id_a, $status_id_a, $status_id_b), + ); + } + + /** + * @covers ::doRefundPayment + */ + public function testDoRefundPayment() { + $payment_status = $this->getMock('\Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface'); + + $this->paymentStatusManager->expects($this->once()) + ->method('createInstance') + ->with($this->pluginDefinition['refund_status_id']) + ->will($this->returnValue($payment_status)); + + $payment = $this->getMockBuilder('\Drupal\payment\Entity\Payment') + ->disableOriginalConstructor() + ->getMock(); + $payment->expects($this->once()) + ->method('save'); + $payment->expects($this->once()) + ->method('setStatus') + ->with($payment_status); + + $this->paymentMethod->setPayment($payment); + + $method = new \ReflectionMethod($this->paymentMethod, 'doRefundPayment'); + $method->setAccessible(TRUE); + + $method->invoke($this->paymentMethod, $payment); + } + + /** + * @covers ::doRefundPaymentAccess + * + * @dataProvider providerDoRefundPaymentAccess + */ + public function testDoRefundPaymentAccess($expected, $refund, $current_status_id, $capture_status_id, $refund_status_id) { + $this->pluginDefinition['capture_status_id'] = $capture_status_id; + $this->pluginDefinition['refund'] = $refund; + $this->pluginDefinition['refund_status_id'] = $refund_status_id; + + $this->paymentMethod = new Basic(array(), '', $this->pluginDefinition, $this->moduleHandler, $this->eventDispatcher, $this->token, $this->paymentStatusManager); + + $payment_status = $this->getMock('\Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface'); + $payment_status->expects($this->any()) + ->method('getPluginId') + ->will($this->returnValue($current_status_id)); + + $payment = $this->getMockBuilder('\Drupal\payment\Entity\Payment') + ->disableOriginalConstructor() + ->getMock(); + $payment->expects($this->any()) + ->method('getStatus') + ->will($this->returnValue($payment_status)); + + $this->paymentMethod->setPayment($payment); + + $account = $this->getMock('\Drupal\Core\Session\AccountInterface'); + + $method = new \ReflectionMethod($this->paymentMethod, 'doRefundPaymentAccess'); + $method->setAccessible(TRUE); + + $this->assertSame($expected, $method->invoke($this->paymentMethod, $account)); + } + + /** + * Provides data to self::testDoRefundPaymentAccess(). + */ + public function providerDoRefundPaymentAccess() { + $status_id_a = $this->randomName(); + $status_id_b = $this->randomName(); + $status_id_c = $this->randomName(); return array( - array(TRUE, TRUE, $status_id_a, $status_id_b), - array(FALSE, FALSE, $status_id_a, $status_id_b), - array(FALSE, TRUE, $status_id_a, $status_id_a), + array(TRUE, TRUE, $status_id_a, $status_id_a, $status_id_b), + array(FALSE, TRUE, $status_id_a, $status_id_b, $status_id_c), + array(FALSE, FALSE, $status_id_a, $status_id_a, $status_id_b), ); } /** + * @covers ::updatePaymentStatusAccess + */ + public function testUpdatePaymentStatusAccess() { + $account = $this->getMock('\Drupal\Core\Session\AccountInterface'); + + $this->assertFalse($this->paymentMethod->updatePaymentStatusAccess($account)); + } + + /** + * @covers ::getSettablePaymentStatuses + */ + public function testGetSettablePaymentStatuses() { + $account = $this->getMock('\Drupal\Core\Session\AccountInterface'); + + $payment = $this->getMockBuilder('\Drupal\payment\Entity\Payment') + ->disableOriginalConstructor() + ->getMock(); + + $this->assertSame(array(), $this->paymentMethod->getSettablePaymentStatuses($account, $payment)); + } + + /** * @covers ::getSupportedCurrencies */ public function testGetSupportedCurrencies() { diff --git a/payment/tests/src/Plugin/Payment/Method/PaymentMethodBaseUnitTest.php b/payment/tests/src/Plugin/Payment/Method/PaymentMethodBaseUnitTest.php index 130f665..93d0c8b 100644 --- a/payment/tests/src/Plugin/Payment/Method/PaymentMethodBaseUnitTest.php +++ b/payment/tests/src/Plugin/Payment/Method/PaymentMethodBaseUnitTest.php @@ -267,14 +267,10 @@ class PaymentMethodBaseUnitTest extends PaymentMethodBaseUnitTestBase { * * @dataProvider providerTestCapturePaymentAccess */ - public function testCapturePaymentAccess($expected, $update_access, $do) { + public function testCapturePaymentAccess($expected, $do) { $payment = $this->getMockBuilder('\Drupal\payment\Entity\Payment') ->disableOriginalConstructor() ->getMock(); - $payment->expects($this->once()) - ->method('access') - ->with('capture') - ->will($this->returnValue($update_access)); $account = $this->getMock('\Drupal\Core\Session\AccountInterface'); @@ -293,10 +289,8 @@ class PaymentMethodBaseUnitTest extends PaymentMethodBaseUnitTestBase { */ public function providerTestCapturePaymentAccess() { return array( - array(TRUE, TRUE, TRUE), - array(FALSE, FALSE, TRUE), - array(FALSE, TRUE, FALSE), - array(FALSE, FALSE, FALSE), + array(TRUE, TRUE), + array(FALSE, FALSE), ); } @@ -348,14 +342,10 @@ class PaymentMethodBaseUnitTest extends PaymentMethodBaseUnitTestBase { * * @dataProvider providerTestRefundPaymentAccess */ - public function testRefundPaymentAccess($expected, $update_access, $do) { + public function testRefundPaymentAccess($expected, $do) { $payment = $this->getMockBuilder('\Drupal\payment\Entity\Payment') ->disableOriginalConstructor() ->getMock(); - $payment->expects($this->once()) - ->method('access') - ->with('refund') - ->will($this->returnValue($update_access)); $account = $this->getMock('\Drupal\Core\Session\AccountInterface'); @@ -374,10 +364,8 @@ class PaymentMethodBaseUnitTest extends PaymentMethodBaseUnitTestBase { */ public function providerTestRefundPaymentAccess() { return array( - array(TRUE, TRUE, TRUE), - array(FALSE, FALSE, TRUE), - array(FALSE, TRUE, FALSE), - array(FALSE, FALSE, FALSE), + array(TRUE, TRUE), + array(FALSE, FALSE), ); } diff --git a/payment/tests/src/Plugin/Payment/MethodConfiguration/BasicUnitTest.php b/payment/tests/src/Plugin/Payment/MethodConfiguration/BasicUnitTest.php index ff9b80c..f7b9e9e 100644 --- a/payment/tests/src/Plugin/Payment/MethodConfiguration/BasicUnitTest.php +++ b/payment/tests/src/Plugin/Payment/MethodConfiguration/BasicUnitTest.php @@ -136,19 +136,68 @@ class BasicUnitTest extends UnitTestCase { } /** + * @covers ::getRefundStatusId + * @covers ::setRefundStatusId + */ + public function testGetRefundStatusId() { + $status = $this->randomName(); + $this->assertSame($this->paymentMethodConfiguration, $this->paymentMethodConfiguration->setRefundStatusId($status)); + $this->assertSame($status, $this->paymentMethodConfiguration->getRefundStatusId()); + } + + /** + * @covers ::getRefund + * @covers ::setRefund + */ + public function testGetRefund() { + $refund = TRUE; + $this->assertSame($this->paymentMethodConfiguration, $this->paymentMethodConfiguration->setRefund($refund)); + $this->assertSame($refund, $this->paymentMethodConfiguration->getRefund()); + } + + /** * @covers ::buildConfigurationForm */ public function testBuildConfigurationForm() { $form = array(); $form_state = array(); $elements = $this->paymentMethodConfiguration->buildConfigurationForm($form, $form_state); + $form['plugin_form']['#process'][] = array($this->paymentMethodConfiguration, 'processBuildConfigurationForm'); + $this->assertArrayHasKey('message', $elements); + $this->assertArrayHasKey('plugin_form', $elements); + $this->assertSame(array(array($this->paymentMethodConfiguration, 'processBuildConfigurationForm')), $elements['plugin_form']['#process']); + } + + /** + * @covers ::processBuildConfigurationForm + */ + public function testProcessBuildConfigurationForm() { + $definitions = array( + array( + 'id' => $this->randomName(), + 'label' => $this->randomName(), + ), + array( + 'id' => $this->randomName(), + 'label' => $this->randomName(), + ), + ); + $this->paymentStatusManager->expects($this->atLeastOnce()) + ->method('getDefinitions') + ->will($this->returnValue($definitions)); + + $element = array(); + $form = array(); + $form_state = array(); + + $method = new \ReflectionMethod($this->paymentMethodConfiguration ,'processBuildConfigurationForm'); + $method->setAccessible(TRUE); + $elements = $method->invokeArgs($this->paymentMethodConfiguration, array(&$element, &$form_state, &$form)); $this->assertInternalType('array', $elements); - foreach (array('brand_label', 'message', 'execute_status_id', 'capture_status_id_wrapper') as $key) { + foreach (array('brand_label', 'execute', 'capture', 'refund') as $key) { $this->assertArrayHasKey($key, $elements); $this->assertInternalType('array', $elements[$key]); } - $this->assertArrayHasKey('capture_status_id', $elements['capture_status_id_wrapper']); - $this->assertInternalType('array', $elements['capture_status_id_wrapper']['capture_status_id']); } /** @@ -160,14 +209,18 @@ class BasicUnitTest extends UnitTestCase { $execute_status_id = $this->randomName(); $capture = TRUE; $capture_status_id = $this->randomName(); + $refund = TRUE; + $refund_status_id = $this->randomName(); $form = array( - 'brand_label' => array( - '#parents' => array('foo', 'bar', 'status') - ), 'message' => array( '#parents' => array('foo', 'bar', 'message') ), + 'plugin_form' => array( + 'brand_label' => array( + '#parents' => array('foo', 'bar', 'status') + ), + ), ); $form_state = array( 'values' => array( @@ -177,9 +230,9 @@ class BasicUnitTest extends UnitTestCase { 'message' => $message, 'execute_status_id' => $execute_status_id, 'capture' => $capture, - 'capture_status_id_wrapper' => array( - 'capture_status_id' => $capture_status_id, - ), + 'capture_status_id' => $capture_status_id, + 'refund' => $refund, + 'refund_status_id' => $refund_status_id, ), ), ), @@ -208,6 +261,9 @@ class BasicUnitTest extends UnitTestCase { namespace { + if (!function_exists('drupal_get_path')) { + function drupal_get_path() {} + } if (!function_exists('drupal_html_id')) { function drupal_html_id() {} }