You are here

public function PostUpdateTest::testPostUpdateTitlePattern in Entity Legal 8.2

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/PostUpdateTest.php \Drupal\Tests\entity_legal\Functional\PostUpdateTest::testPostUpdateTitlePattern()
  2. 3.0.x tests/src/Functional/PostUpdateTest.php \Drupal\Tests\entity_legal\Functional\PostUpdateTest::testPostUpdateTitlePattern()

Tests entity_legal_post_update_title_pattern().

See also

entity_legal_post_update_title_pattern()

File

tests/src/Functional/PostUpdateTest.php, line 32

Class

PostUpdateTest
Tests the post-update functions.

Namespace

Drupal\Tests\entity_legal\Functional

Code

public function testPostUpdateTitlePattern() {
  $factory = \Drupal::configFactory();
  foreach ($factory
    ->listAll('entity_legal.document.') as $name) {
    $settings = $factory
      ->get($name)
      ->get('settings');

    // Check that the 'settings.title_pattern' property doesn't exist yet.
    $this
      ->assertArrayNotHasKey('title_pattern', $settings);
  }

  // Run updates.
  $this
    ->runUpdates();
  foreach ($factory
    ->listAll('entity_legal.document.') as $name) {
    $settings = $factory
      ->get($name)
      ->get('settings');

    // Check that the 'settings.title_pattern' property has been added.
    $this
      ->assertArrayHasKey('title_pattern', $settings);

    // Check the 'settings.title_pattern' property value.
    $this
      ->assertSame('[entity_legal_document:published-version:label]', $settings['title_pattern']);
  }
}