/** * @covers ::getOperations */ public function testGetOperations() { $entity_id = $this->randomMachineName(); $plugin_id = 'payment_config:' . $entity_id; $payment_status = $this->getMock(PaymentStatusInterface::class); $this->paymentStatusStorage->expects($this->once())->method('load')->with($entity_id)->willReturn($payment_status); $operations = array('foo' => array('title' => $this->randomMachineName())); $this->paymentStatusListBuilder->expects($this->once())->method('getOperations')->with($payment_status)->willReturn($operations); $this->assertSame($operations, $this->sut->getOperations($plugin_id)); }
/** * {@inheritdoc} */ public function getOperations($plugin_id) { $payment_method_configuration_operations = $this->paymentMethodConfigurationListBuilder->getOperations($this->getPaymentMethodConfiguration($plugin_id)); $titles = array('edit' => $this->t('Edit configuration'), 'delete' => $this->t('Delete configuration'), 'enable' => $this->t('Enable configuration'), 'disable' => $this->t('Disable configuration')); $operations = []; foreach ($payment_method_configuration_operations as $name => $payment_method_configuration_operation) { if (array_key_exists($name, $titles)) { $operations[$name] = $payment_method_configuration_operation; $operations[$name]['title'] = $titles[$name]; $operations[$name]['query']['destination'] = $this->redirectDestination->get(); } } return $operations; }
/** * @covers ::getOperations */ public function testGetOperations() { $list_builder_operations = ['edit' => ['title' => 'Edit configuration'], 'delete' => ['title' => 'Delete configuration'], 'enable' => ['title' => 'Enable configuration'], 'disable' => ['title' => 'Disable configuration'], 'foo' => []]; $destination = $this->randomMachineName(); $this->redirectDestination->expects($this->atLeastOnce())->method('get')->willReturn($destination); $plugin_id = $this->randomMachineName(); $payment_method_configuration = $this->getMock(PaymentMethodConfigurationInterface::class); $this->sut->expects($this->once())->method('getPaymentMethodConfiguration')->with($plugin_id)->willReturn($payment_method_configuration); $this->paymentMethodConfigurationListBuilder->expects($this->once())->method('getOperations')->with($payment_method_configuration)->willReturn($list_builder_operations); $expected_operations = $list_builder_operations; unset($expected_operations['foo']); foreach ($expected_operations as $name => $expected_operation) { $expected_operations[$name]['title'] = $list_builder_operations[$name]['title']; $expected_operations[$name]['query']['destination'] = $destination; } $this->assertEquals($expected_operations, $this->sut->getOperations($plugin_id)); }
/** * {@inheritdoc} */ public function getOperations($plugin_id) { $entity_id = substr($plugin_id, 15); $entity = $this->paymentStatusStorage->load($entity_id); return $this->paymentStatusListBuilder->getOperations($entity); }