public function BlockUpgradePathTest::testBlockUpgradeTitleLength

Tests block title length after successful upgrade.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php, line 35
Definition of Drupal\system\Tests\Upgrade\BlockUpgradePathTest.

Class

BlockUpgradePathTest
Tests upgrading a bare database.

Namespace

Drupal\system\Tests\Upgrade

Code

public function testBlockUpgradeTitleLength() {
  $this
    ->assertTrue($this
    ->performUpgrade(), 'The upgrade was completed successfully.');

  // Add a new custom block with a title of 255 characters.
  $block_title_1 = $this
    ->randomName(255);
  $custom_block_1 = array();
  $custom_block_1['title'] = $block_title_1;
  $custom_block_1['info'] = $this
    ->randomName(8);
  $custom_block_1['body[value]'] = $this
    ->randomName(32);
  $custom_block_1['regions[bartik]'] = 'sidebar_first';
  $this
    ->drupalPost('admin/structure/block/add', $custom_block_1, t('Save block'));

  // Confirm that the custom block has been created, and title matches input.
  $this
    ->drupalGet('');
  $this
    ->assertText($block_title_1, 'Block with title longer than 64 characters successfully created.');

  // Add a new custom block with a title over 255 characters.
  $block_title_2 = $this
    ->randomName(256);
  $custom_block_2 = array();
  $custom_block_2['title'] = $block_title_2;
  $custom_block_2['info'] = $this
    ->randomName(8);
  $custom_block_2['body[value]'] = $this
    ->randomName(32);
  $this
    ->drupalPost('admin/structure/block/add', $custom_block_2, t('Save block'));

  // Confirm that the custom block cannot be created with title longer than
  // the maximum number of characters.
  $this
    ->assertText('Block title cannot be longer than 255 characters', 'Block with title longer than 255 characters created unsuccessfully.');
}