class EntityUuidIdTest
Tests that an entity with a UUID as ID can be managed.
@group Entity
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait
- class \Drupal\FunctionalTests\Entity\EntityUuidIdTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\content_translation\Traits\ContentTranslationTestTrait
Expanded class hierarchy of EntityUuidIdTest
File
-
core/
tests/ Drupal/ FunctionalTests/ Entity/ EntityUuidIdTest.php, line 16
Namespace
Drupal\FunctionalTests\EntityView source
class EntityUuidIdTest extends BrowserTestBase {
use ContentTranslationTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'content_translation',
'entity_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->createLanguageFromLangcode('af');
$this->enableContentTranslation('entity_test_uuid_id', 'entity_test_uuid_id');
$this->drupalPlaceBlock('page_title_block');
$this->drupalPlaceBlock('local_tasks_block');
}
/**
* Tests the user interface for the test entity.
*/
public function testUi() : void {
$this->drupalLogin($this->createUser([
'administer entity_test content',
'create content translations',
'translate entity_test_uuid_id',
'view test entity',
]));
// Test adding an entity.
$this->drupalGet('/entity_test_uuid_id/add');
$this->submitForm([
'Name' => 'Test entity with UUID ID',
], 'Save');
$this->assertSession()
->elementTextEquals('css', 'h1', 'Edit Test entity with UUID ID');
$this->assertSession()
->addressMatches('#^/entity_test_uuid_id/manage/' . Uuid::VALID_PATTERN . '/edit$#');
// Test translating an entity.
$this->clickLink('Translate');
$this->clickLink('Add');
$this->submitForm([
'Name' => 'Afrikaans translation of test entity with UUID ID',
], 'Save');
$this->assertSession()
->elementTextEquals('css', 'h1', 'Afrikaans translation of test entity with UUID ID [Afrikaans translation]');
$this->assertSession()
->addressMatches('#^/af/entity_test_uuid_id/manage/' . Uuid::VALID_PATTERN . '/edit$#');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.