You are here

private function XBBCodeAdminTest::createCustomTag in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/XBBCodeAdminTest.php \Drupal\Tests\xbbcode\Functional\XBBCodeAdminTest::createCustomTag()

Generate a custom tag and return it.

Parameters

bool $save: Set to false to skip the save operation.

Return value

array Information about the created tag.

Throws

\Behat\Mink\Exception\ExpectationException

4 calls to XBBCodeAdminTest::createCustomTag()
XBBCodeAdminTest::setUp in tests/src/Functional/XBBCodeAdminTest.php
XBBCodeAdminTest::testCustomTags in tests/src/Functional/XBBCodeAdminTest.php
Test the custom tag page.
XBBCodeAdminTest::testGlobalPlugins in tests/src/Functional/XBBCodeAdminTest.php
Test the global default plugins.
XBBCodeAdminTest::testTagSet in tests/src/Functional/XBBCodeAdminTest.php
Create and edit a tag set.

File

tests/src/Functional/XBBCodeAdminTest.php, line 93

Class

XBBCodeAdminTest
Test the administrative interface.

Namespace

Drupal\Tests\xbbcode\Functional

Code

private function createCustomTag($save = TRUE) : array {
  $name = mb_strtolower($this
    ->randomMachineName());
  $option = $this
    ->randomString();
  $tag = [
    'id' => mb_strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
    'description' => $this
      ->randomString(),
    'name' => $name,
    'sample' => "[{$name}='{$option}']" . $this
      ->randomMachineName() . "[/{$name}]",
    'template_code' => '[' . $this
      ->randomMachineName() . '|{{ tag.option }}|{{ tag.content }}]',
    'attached[library]' => "xbbcode/tag-form\nxbbcode_test_plugin/test-library",
  ];
  if ($save) {
    $this
      ->drupalGet('admin/config/content/xbbcode/tags/add');
    $this
      ->submitForm($tag, 'Save');
    $this
      ->assertSession()
      ->responseContains((string) new FormattableMarkup('The BBCode tag %tag has been created.', [
      '%tag' => $tag['label'],
    ]));
  }
  return $tag;
}