public function FlagServiceTest::testFlagServiceGetFlag in Flag 8.4
Tests that flags once created can be retrieved.
File
- tests/
src/ Kernel/ FlagServiceTest.php, line 19
Class
- FlagServiceTest
- Tests the FlagService.
Namespace
Drupal\Tests\flag\KernelCode
public function testFlagServiceGetFlag() {
// Create a flag.
$flag = Flag::create([
'id' => strtolower($this
->randomMachineName()),
'label' => $this
->randomString(),
'entity_type' => 'node',
'bundles' => [
'article',
],
'flag_type' => 'entity:node',
'link_type' => 'reload',
'flagTypeConfig' => [],
'linkTypeConfig' => [],
]);
$flag
->save();
// Search for flag.
$user_with_access = $this
->createUser([
'flag ' . $flag
->id(),
]);
$result = $this->flagService
->getAllFlags('node', 'article');
$this
->assertIdentical(count($result), 1, 'Found flag type');
$this
->assertEquals([
$flag
->id(),
], array_keys($result));
}