You are here

public function BlockUiTest::testMachineNameSuggestion in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block/src/Tests/BlockUiTest.php \Drupal\block\Tests\BlockUiTest::testMachineNameSuggestion()

Tests that the BlockForm populates machine name correctly.

File

core/modules/block/src/Tests/BlockUiTest.php, line 259
Contains \Drupal\block\Tests\BlockUiTest.

Class

BlockUiTest
Tests that the block configuration UI exists and stores data correctly.

Namespace

Drupal\block\Tests

Code

public function testMachineNameSuggestion() {
  $url = 'admin/structure/block/add/test_block_instantiation/classy';
  $this
    ->drupalGet($url);
  $this
    ->assertFieldByName('id', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.');
  $this
    ->drupalPostForm($url, array(), 'Save block');

  // Now, check to make sure the form starts by autoincrementing correctly.
  $this
    ->drupalGet($url);
  $this
    ->assertFieldByName('id', 'displaymessage_2', 'Block form appends _2 to plugin-suggested machine name when an instance already exists.');
  $this
    ->drupalPostForm($url, array(), 'Save block');

  // And verify that it continues working beyond just the first two.
  $this
    ->drupalGet($url);
  $this
    ->assertFieldByName('id', 'displaymessage_3', 'Block form appends _3 to plugin-suggested machine name when two instances already exist.');
}