/**
  * @covers ::save
  */
 public function testSave()
 {
     $url = new Url($this->randomMachineName());
     $this->paymentMethodConfiguration->expects($this->once())->method('save');
     $this->paymentMethodConfiguration->expects($this->atLeastOnce())->method('urlinfo')->with('collection')->willReturn($url);
     $form_state = $this->getMock(FormStateInterface::class);
     $form_state->expects($this->once())->method('setRedirectUrl')->with($url);
     /** @var \Drupal\payment\Entity\PaymentMethodConfiguration\PaymentMethodConfigurationForm|\PHPUnit_Framework_MockObject_MockObject $form */
     $this->sut = $this->getMockBuilder(PaymentMethodConfigurationForm::class)->setConstructorArgs(array($this->stringTranslation, $this->currentUser, $this->paymentMethodConfigurationStorage, $this->paymentMethodConfigurationManager))->setMethods(array('copyFormValuesToEntity'))->getMock();
     $this->sut->setEntity($this->paymentMethodConfiguration);
     $this->sut->save([], $form_state);
 }
 /**
  * {@inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->paymentStorage = \Drupal::entityManager()->getStorage('payment');
     /** @var \Drupal\currency\ConfigImporterInterface $config_importer */
     $config_importer = \Drupal::service('currency.config_importer');
     $config_importer->importCurrency('EUR');
     // Create the field and field instance.
     $field_name = strtolower($this->randomMachineName());
     entity_create('field_storage_config', ['cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED, 'entity_type' => 'user', 'field_name' => $field_name, 'type' => 'payment_form'])->save();
     entity_create('field_config', ['bundle' => 'user', 'entity_type' => 'user', 'field_name' => $field_name, 'settings' => ['currency_code' => 'EUR']])->save();
     entity_get_display('user', 'user', 'default')->setComponent($field_name, ['type' => 'payment_form'])->save();
     // Create an entity.
     $this->user = entity_create('user', ['name' => $this->randomString(), 'status' => TRUE]);
     foreach (Generate::createPaymentLineItems() as $line_item) {
         $this->user->get($field_name)->appendItem(['plugin_id' => $line_item->getPluginId(), 'plugin_configuration' => $line_item->getConfiguration()]);
     }
     $this->user->save();
     // Create a payment method.
     $this->paymentMethod = Generate::createPaymentMethodConfiguration(2, 'payment_basic');
     $this->paymentMethod->setPluginConfiguration(['execute_status_id' => $this->executeStatusPluginId]);
     $this->paymentMethod->save();
 }
 /**
  * @covers ::setUuid
  * @covers ::uuid
  */
 public function testUuid()
 {
     $uuid = $this->randomMachineName();
     $this->assertSame($this->sut, $this->sut->setUuid($uuid));
     $this->assertSame($uuid, $this->sut->uuid());
 }