FlagKernelTestBase.php in Flag 8.4
File
tests/src/Kernel/FlagKernelTestBase.php
View source
<?php
namespace Drupal\Tests\flag\Kernel;
use Drupal\flag\FlagInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\Tests\flag\Traits\FlagCreateTrait;
abstract class FlagKernelTestBase extends KernelTestBase {
use FlagCreateTrait;
use UserCreationTrait;
protected $flagService;
public static $modules = [
'field',
'filter',
'flag',
'node',
'text',
'user',
'system',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->installEntitySchema('flagging');
$this
->installSchema('system', [
'sequences',
]);
$this
->installSchema('flag', [
'flag_counts',
]);
$this
->installSchema('node', [
'node_access',
]);
$this
->installConfig([
'filter',
'flag',
'node',
]);
$this->flagService = \Drupal::service('flag');
}
protected function getFlagFlaggings(FlagInterface $flag) {
$query = \Drupal::entityQuery('flagging');
$query
->condition('flag_id', $flag
->id());
$ids = $query
->execute();
return \Drupal::entityTypeManager()
->getStorage('flagging')
->loadMultiple($ids);
}
}