You are here

public function TransactionAdminTest::doTestAddTransactionOperation in Transaction 8

Tests the transaction operation creation from the admin UI.

See also

\Drupal\transaction\Form\TransactionOperationForm

File

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

Class

TransactionAdminTest
Tests the transaction administration.

Namespace

Drupal\Tests\transaction\Functional

Code

public function doTestAddTransactionOperation() {

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

  // It must be the first transaction operation to be added.
  $this
    ->assertSession()
    ->pageTextContains('No transaction operations available.');
  $this
    ->clickLink('Add transaction operation');
  $post = [
    'label' => 'Test operation',
    'id' => 'test_operation',
    'description' => 'Transaction operation description',
    'details' => 'Details line line 1' . PHP_EOL . 'Details line line 2',
  ];
  $this
    ->drupalPostForm(NULL, $post, 'Save transaction operation');

  // Check the creation message.
  $this
    ->assertSession()
    ->pageTextContains('Transaction operation Test operation has been added.');

  // Check the created transaction type values.

  /** @var \Drupal\transaction\TransactionOperationInterface $transaction_operation */
  $transaction_operation = TransactionOperation::load('test_operation');
  $this
    ->assertEquals($transaction_operation
    ->getTransactionTypeId(), 'generic_workflow');
  $this
    ->assertEquals($transaction_operation
    ->label(), $post['label']);
  $this
    ->assertEquals($transaction_operation
    ->getDescription(), $post['description']);
  $details = explode(PHP_EOL, $post['details']);
  $this
    ->assertEquals($transaction_operation
    ->getDetails(), $details);
}