class EntityLoadByUuidTest in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityLoadByUuidTest.php \Drupal\KernelTests\Core\Entity\EntityLoadByUuidTest
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityLoadByUuidTest.php \Drupal\KernelTests\Core\Entity\EntityLoadByUuidTest
Tests loading entities by UUID.
@group entity
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\KernelTests\Core\Entity\EntityLoadByUuidTest
Expanded class hierarchy of EntityLoadByUuidTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityLoadByUuidTest.php, line 13
Namespace
Drupal\KernelTests\Core\EntityView source
class EntityLoadByUuidTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'entity_test',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('entity_test');
}
/**
* Ensures that ::loadEntityByUuid() doesn't apply access checking.
*/
public function testLoadEntityByUuidAccessChecking() {
\Drupal::state()
->set('entity_test_query_access', TRUE);
// Create two test entities.
$entity_0 = EntityTest::create([
'type' => 'entity_test',
'name' => 'published entity',
]);
$entity_0
->save();
$entity_1 = EntityTest::create([
'type' => 'entity_test',
'name' => 'unpublished entity',
]);
$entity_1
->save();
/** @var \Drupal\Core\Entity\EntityRepositoryInterface $repository */
$repository = \Drupal::service('entity.repository');
$this
->assertEquals($entity_0
->id(), $repository
->loadEntityByUuid('entity_test', $entity_0
->uuid())
->id());
$this
->assertEquals($entity_1
->id(), $repository
->loadEntityByUuid('entity_test', $entity_1
->uuid())
->id());
}
}