You are here

public function TransactionAdminTest::doTestAddBasicTransactionType in Transaction 8

Tests the transaction type add form.

See also

\Drupal\transaction\Form\TransactionTypeAddForm

\Drupal\transaction\Form\TransactionTypeEditForm

1 call to TransactionAdminTest::doTestAddBasicTransactionType()
TransactionAdminTest::testAdmin in tests/src/Functional/TransactionAdminTest.php
Full admin test sequence.

File

tests/src/Functional/TransactionAdminTest.php, line 65

Class

TransactionAdminTest
Tests the transaction administration.

Namespace

Drupal\Tests\transaction\Functional

Code

public function doTestAddBasicTransactionType() {

  // Go to export (restore) block with the default content page.
  $this
    ->drupalGet('admin/config/workflow/transaction');
  $this
    ->clickLink('Add transaction type');

  // Confirm the form.
  $transactor = 'transaction_generic';
  $target_entity_type = 'entity_test';
  $post = [
    'target_entity_type' => $target_entity_type,
    'transactor' => $transactor,
  ];
  $this
    ->drupalPostForm(NULL, $post, 'Continue');
  $label = 'Generic workflow';
  $id = 'generic_workflow';
  $post = [
    'label' => $label,
    'id' => $id,
  ];
  $this
    ->drupalPostForm(NULL, $post, 'Create transaction type');

  // Check the created transaction type values.

  /** @var \Drupal\transaction\TransactionTypeInterface $transaction_type */
  $transaction_type = TransactionType::load($id);
  $this
    ->assertNotNull($transaction_type);
  $this
    ->assertEqual($transaction_type
    ->label(), $label);
  $this
    ->assertEqual($transaction_type
    ->getTargetEntityTypeId(), $target_entity_type);
  $this
    ->assertEqual($transaction_type
    ->getPluginId(), $transactor);

  /** @var \Drupal\transaction\TransactorPluginInterface $transactor_plugin */
  $transactor_plugin = $transaction_type
    ->getPlugin();

  // Check that the transactor has no configuration (uses default options).
  $this
    ->assertEmpty($transactor_plugin
    ->getConfiguration());
}