function FilterFormatRepositoryTest::testGetFormatsByRole

Same name and namespace in other branches
  1. main core/modules/filter/tests/src/Kernel/FilterFormatRepositoryTest.php \Drupal\Tests\filter\Kernel\FilterFormatRepositoryTest::testGetFormatsByRole()

@legacy-covers ::getFormatsByRole

File

core/modules/filter/tests/src/Kernel/FilterFormatRepositoryTest.php, line 79

Class

FilterFormatRepositoryTest
Tests the Drupal\filter\FilterFormatRepositoryInterface service.

Namespace

Drupal\Tests\filter\Kernel

Code

public function testGetFormatsByRole() : void {
  Role::create([
    'id' => 'role1',
    'label' => 'Role 1',
    'permissions' => [
      'use text format foo',
    ],
  ])->save();
  $this->createUser(values: [
    'roles' => [
      'role1',
    ],
  ])
    ->save();
  // The 'plain_text' format weight is 10.
  $this->assertSame([
    'plain_text',
    'foo',
  ], array_keys($this->repository
    ->getFormatsByRole('role1')));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.