class EntityDecoupledTranslationRevisionsTest in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest
Test decoupled translation revisions.
@group entity
@coversDefaultClass \Drupal\Core\Entity\ContentEntityStorageBase
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses AssertContentTrait, AssertLegacyTrait, AssertHelperTrait, ConfigTestTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses DeprecatedServicePropertyTrait, UserCreationTrait
- class \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses DeprecatedServicePropertyTrait, UserCreationTrait
Expanded class hierarchy of EntityDecoupledTranslationRevisionsTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityDecoupledTranslationRevisionsTest.php, line 18
Namespace
Drupal\KernelTests\Core\EntityView source
class EntityDecoupledTranslationRevisionsTest extends EntityKernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'system',
'entity_test',
'language',
];
/**
* The entity type bundle info service.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $bundleInfo;
/**
* The entity storage.
*
* @var \Drupal\Core\Entity\ContentEntityStorageInterface
*/
protected $storage;
/**
* The translations of the test entity.
*
* @var \Drupal\Core\Entity\ContentEntityInterface[]
*/
protected $translations;
/**
* The previous revision identifiers for the various revision translations.
*
* @var int[]
*/
protected $previousRevisionId = [];
/**
* The previous untranslatable field value.
*
* @var string[]
*/
protected $previousUntranslatableFieldValue;
/**
* The current edit sequence step index.
*
* @var int
*/
protected $stepIndex;
/**
* The current edit sequence step info.
*
* @var array
*/
protected $stepInfo;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$entity_type_id = 'entity_test_mulrev';
$this
->installEntitySchema($entity_type_id);
$this->storage = $this->container
->get('entity_type.manager')
->getStorage($entity_type_id);
$this
->installConfig([
'language',
]);
$langcodes = [
'it',
'fr',
];
foreach ($langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)
->save();
}
$values = [
'name' => $this
->randomString(),
'status' => 1,
];
User::create($values)
->save();
// Make sure entity bundles are translatable.
$this->state
->set('entity_test.translation', TRUE);
$this->bundleInfo = \Drupal::service('entity_type.bundle.info');
$this->bundleInfo
->clearCachedBundles();
}
/**
* Data provider for ::testDecoupledDefaultRevisions.
*/
public function dataTestDecoupledPendingRevisions() {
$sets = [];
$sets['Intermixed languages - No initial default translation'][] = [
[
'en',
TRUE,
],
[
'en',
FALSE,
],
[
'it',
FALSE,
],
[
'en',
FALSE,
],
[
'it',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
TRUE,
],
];
$sets['Intermixed languages - With initial default translation'][] = [
[
'en',
TRUE,
],
[
'it',
TRUE,
],
[
'en',
FALSE,
],
[
'it',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
TRUE,
],
];
$sets['Alternate languages - No initial default translation'][] = [
[
'en',
TRUE,
],
[
'en',
FALSE,
],
[
'en',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
FALSE,
],
[
'it',
FALSE,
],
[
'it',
TRUE,
],
];
$sets['Alternate languages - With initial default translation'][] = [
[
'en',
TRUE,
],
[
'it',
TRUE,
],
[
'en',
TRUE,
],
[
'en',
FALSE,
],
[
'en',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
TRUE,
],
[
'it',
FALSE,
],
[
'it',
FALSE,
],
[
'it',
TRUE,
],
];
$sets['Multiple languages - No initial default translation'][] = [
[
'en',
TRUE,
],
[
'it',
FALSE,
],
[
'fr',
FALSE,
],
[
'en',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
TRUE,
],
[
'fr',
FALSE,
],
[
'en',
FALSE,
],
[
'it',
FALSE,
],
[
'en',
TRUE,
],
[
'fr',
TRUE,
],
[
'it',
TRUE,
],
[
'fr',
TRUE,
],
];
$sets['Multiple languages - With initial default translation'][] = [
[
'en',
TRUE,
],
[
'it',
TRUE,
],
[
'fr',
TRUE,
],
[
'en',
FALSE,
],
[
'it',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
TRUE,
],
[
'fr',
FALSE,
],
[
'en',
FALSE,
],
[
'it',
FALSE,
],
[
'en',
TRUE,
],
[
'fr',
TRUE,
],
[
'it',
TRUE,
],
[
'fr',
TRUE,
],
];
return $sets;
}
/**
* Test decoupled default revisions.
*
* @param array[] $sequence
* An array with arrays of arguments for the ::doSaveNewRevision() method as
* values. Every child array corresponds to a method invocation.
*
* @covers ::createRevision
*
* @dataProvider dataTestDecoupledPendingRevisions
*/
public function testDecoupledPendingRevisions($sequence) {
$revision_id = $this
->doTestEditSequence($sequence);
$this
->assertEquals(count($sequence), $revision_id);
}
/**
* Data provider for ::testUntranslatableFields.
*/
public function dataTestUntranslatableFields() {
$sets = [];
$sets['Default behavior - Untranslatable fields affect all revisions'] = [
[
[
'en',
TRUE,
TRUE,
],
[
'it',
FALSE,
TRUE,
FALSE,
],
[
'en',
FALSE,
TRUE,
FALSE,
],
[
'en',
TRUE,
TRUE,
],
[
'it',
TRUE,
TRUE,
],
[
'en',
FALSE,
],
[
'it',
FALSE,
],
[
'en',
TRUE,
],
[
'it',
TRUE,
],
],
FALSE,
];
$sets['Alternative behavior - Untranslatable fields affect only default translation'] = [
[
[
'en',
TRUE,
TRUE,
],
[
'it',
FALSE,
TRUE,
FALSE,
],
[
'en',
FALSE,
TRUE,
],
[
'it',
TRUE,
TRUE,
FALSE,
],
[
'it',
FALSE,
],
[
'it',
TRUE,
],
[
'en',
TRUE,
TRUE,
],
[
'it',
FALSE,
],
[
'en',
FALSE,
],
[
'it',
TRUE,
],
[
'en',
TRUE,
TRUE,
],
],
TRUE,
];
return $sets;
}
/**
* Tests that untranslatable fields are handled correctly.
*
* @param array[] $sequence
* An array with arrays of arguments for the ::doSaveNewRevision() method as
* values. Every child array corresponds to a method invocation.
*
* @param bool $default_translation_affected
* Whether untranslatable field changes affect all revisions or only the
* default revision.
*
* @covers ::createRevision
* @covers \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::validate
*
* @dataProvider dataTestUntranslatableFields
*/
public function testUntranslatableFields($sequence, $default_translation_affected) {
// Configure the untranslatable fields edit mode.
$this->state
->set('entity_test.untranslatable_fields.default_translation_affected', $default_translation_affected);
$this->bundleInfo
->clearCachedBundles();
// Test that a new entity is always valid.
$entity = EntityTestMulRev::create();
$entity
->set('non_mul_field', 0);
$violations = $entity
->validate();
$this
->assertEmpty($violations);
// Test the specified sequence.
$this
->doTestEditSequence($sequence);
}
/**
* Actually tests an edit step sequence.
*
* @param array[] $sequence
* An array of sequence steps.
*
* @return int
* The latest saved revision id.
*/
protected function doTestEditSequence($sequence) {
$revision_id = NULL;
foreach ($sequence as $index => $step) {
$this->stepIndex = $index;
$revision_id = call_user_func_array([
$this,
'doEditStep',
], $step);
}
return $revision_id;
}
/**
* Saves a new revision of the test entity.
*
* @param string $active_langcode
* The language of the translation for which a new revision will be saved.
* @param bool $default_revision
* Whether the revision should be flagged as the default revision.
* @param bool $untranslatable_update
* (optional) Whether an untranslatable field update should be performed.
* Defaults to FALSE.
* @param bool $valid
* (optional) Whether entity validation is expected to succeed. Defaults to
* TRUE.
*
* @return int
* The new revision identifier.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
protected function doEditStep($active_langcode, $default_revision, $untranslatable_update = FALSE, $valid = TRUE) {
$this->stepInfo = [
$active_langcode,
$default_revision,
$untranslatable_update,
$valid,
];
// If changes to untranslatable fields affect only the default translation,
// we can different values for untranslatable fields in the various
// revision translations, so we need to track their previous value per
// language.
$all_translations_affected = !$this->state
->get('entity_test.untranslatable_fields.default_translation_affected');
$previous_untranslatable_field_langcode = $all_translations_affected ? LanguageInterface::LANGCODE_DEFAULT : $active_langcode;
// Initialize previous data tracking.
if (!isset($this->translations)) {
$this->translations[$active_langcode] = EntityTestMulRev::create();
$this->previousRevisionId[$active_langcode] = 0;
$this->previousUntranslatableFieldValue[$previous_untranslatable_field_langcode] = NULL;
}
if (!isset($this->translations[$active_langcode])) {
$this->translations[$active_langcode] = reset($this->translations)
->addTranslation($active_langcode);
$this->previousRevisionId[$active_langcode] = 0;
$this->previousUntranslatableFieldValue[$active_langcode] = NULL;
}
// We want to update previous data only if we expect a valid result,
// otherwise we would be just polluting it with invalid values.
if ($valid) {
$entity =& $this->translations[$active_langcode];
$previous_revision_id =& $this->previousRevisionId[$active_langcode];
$previous_untranslatable_field_value =& $this->previousUntranslatableFieldValue[$previous_untranslatable_field_langcode];
}
else {
$entity = clone $this->translations[$active_langcode];
$previous_revision_id = $this->previousRevisionId[$active_langcode];
$previous_untranslatable_field_value = $this->previousUntranslatableFieldValue[$previous_untranslatable_field_langcode];
}
// Check that after instantiating a new revision for the specified
// translation, we are resuming work from where we left the last time. If
// that is the case, the label generated for the previous revision should
// match the stored one.
if (!$entity
->isNew()) {
$previous_label = NULL;
if (!$entity
->isNewTranslation()) {
$previous_label = $this
->generateNewEntityLabel($entity, $previous_revision_id);
$latest_affected_revision_id = $this->storage
->getLatestTranslationAffectedRevisionId($entity
->id(), $entity
->language()
->getId());
}
else {
// Normally it would make sense to load the default revision in this
// case, however that would mean simulating here the logic that we need
// to test, thus "masking" possible flaws. To avoid that, we simply
// pretend we are starting from an earlier non translated revision.
// This ensures that the we can check that the merging logic is applied
// also when adding a new translation.
$latest_affected_revision_id = 1;
}
$previous_revision_id = (int) $entity
->getLoadedRevisionId();
/** @var \Drupal\Core\Entity\ContentEntityInterface $latest_affected_revision */
$latest_affected_revision = $this->storage
->loadRevision($latest_affected_revision_id);
$translation = $latest_affected_revision
->hasTranslation($active_langcode) ? $latest_affected_revision
->getTranslation($active_langcode) : $latest_affected_revision
->addTranslation($active_langcode);
$entity = $this->storage
->createRevision($translation, $default_revision);
$this
->assertEquals($default_revision, $entity
->isDefaultRevision());
$this
->assertEquals($translation
->getLoadedRevisionId(), $entity
->getLoadedRevisionId());
$this
->assertEquals($previous_label, $entity
->label(), $this
->formatMessage('Loaded translatable field value does not match the previous one.'));
}
// Check that the previous untranslatable field value is loaded in the new
// revision as expected. When we are dealing with a non default translation
// the expected value is always the one stored in the default revision, as
// untranslatable fields can only be changed in the default translation or
// in the default revision, depending on the configured mode.
$value = $entity
->get('non_mul_field')->value;
if (isset($previous_untranslatable_field_value)) {
$this
->assertEquals($previous_untranslatable_field_value, $value, $this
->formatMessage('Loaded untranslatable field value does not match the previous one.'));
}
elseif (!$entity
->isDefaultTranslation()) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $default_revision */
$default_revision = $this->storage
->loadUnchanged($entity
->id());
$expected_value = $default_revision
->get('non_mul_field')->value;
$this
->assertEquals($expected_value, $value, $this
->formatMessage('Loaded untranslatable field value does not match the previous one.'));
}
// Perform a change and store it.
$label = $this
->generateNewEntityLabel($entity, $previous_revision_id, TRUE);
$entity
->set('name', $label);
if ($untranslatable_update) {
// Store the revision ID of the previous untranslatable fields update in
// the new value, besides the upcoming revision ID. Useful to analyze test
// failures.
$prev = 0;
if (isset($previous_untranslatable_field_value)) {
preg_match('/^\\d+ -> (\\d+)$/', $previous_untranslatable_field_value, $matches);
$prev = $matches[1];
}
$value = $prev . ' -> ' . ($entity
->getLoadedRevisionId() + 1);
$entity
->set('non_mul_field', $value);
$previous_untranslatable_field_value = $value;
}
$violations = $entity
->validate();
$messages = [];
foreach ($violations as $violation) {
/** \Symfony\Component\Validator\ConstraintViolationInterface */
$messages[] = $violation
->getMessage();
}
$this
->assertEquals($valid, !$violations
->count(), $this
->formatMessage('Validation does not match the expected result: %s', implode(', ', $messages)));
if ($valid) {
$entity
->save();
// Reload the current revision translation and the default revision to
// make sure data was stored correctly.
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->storage
->loadRevision($entity
->getRevisionId());
$entity = $entity
->getTranslation($active_langcode);
/** @var \Drupal\Core\Entity\ContentEntityInterface $default_entity */
$default_entity = $this->storage
->loadUnchanged($entity
->id());
// Verify that the values for the current revision translation match the
// expected ones, while for the other translations they match the default
// revision. We also need to verify that only the current revision
// translation was marked as affected.
foreach ($entity
->getTranslationLanguages() as $langcode => $language) {
$translation = $entity
->getTranslation($langcode);
$rta_expected = $langcode == $active_langcode || $untranslatable_update && $all_translations_affected;
$this
->assertEquals($rta_expected, $translation
->isRevisionTranslationAffected(), $this
->formatMessage("'{$langcode}' translation incorrectly affected"));
$label_expected = $label;
if ($langcode !== $active_langcode) {
$default_translation = $default_entity
->hasTranslation($langcode) ? $default_entity
->getTranslation($langcode) : $default_entity;
$label_expected = $default_translation
->label();
}
$this
->assertEquals($label_expected, $translation
->label(), $this
->formatMessage("Incorrect '{$langcode}' translation label"));
}
}
return $entity
->getRevisionId();
}
/**
* Generates a new label for the specified revision.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $revision
* An entity object.
* @param int $previous_revision_id
* The previous revision identifier for this revision translation.
* @param bool $next
* (optional) Whether the label describes the current revision or the one
* to be created. Defaults to FALSE.
*
* @return string
* A revision label.
*/
protected function generateNewEntityLabel(ContentEntityInterface $revision, $previous_revision_id, $next = FALSE) {
$language_label = $revision
->language()
->getName();
$revision_type = $revision
->isDefaultRevision() ? 'Default' : 'Pending';
$revision_id = $next ? $this->storage
->getLatestRevisionId($revision
->id()) + 1 : $revision
->getLoadedRevisionId();
return sprintf('%s (%s %d -> %d)', $language_label, $revision_type, $previous_revision_id, $revision_id);
}
/**
* Formats an assertion message.
*
* @param string $message
* The human-readable message.
*
* @return string
* The formatted message.
*/
protected function formatMessage($message) {
$args = func_get_args();
array_shift($args);
$params = array_merge($args, $this->stepInfo);
array_unshift($params, $this->stepIndex + 1);
array_unshift($params, '[Step %d] ' . $message . ' (langcode: %s, default_revision: %d, untranslatable_update: %d, valid: %d)');
return call_user_func_array('sprintf', $params);
}
/**
* Checks that changes to multiple translations are handled correctly.
*
* @covers ::createRevision
* @covers \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::validate
*/
public function testMultipleTranslationChanges() {
// Configure the untranslatable fields edit mode.
$this->state
->set('entity_test.untranslatable_fields.default_translation_affected', TRUE);
$this->bundleInfo
->clearCachedBundles();
$entity = EntityTestMulRev::create();
$entity
->get('name')->value = 'Test 1.1 EN';
$entity
->get('non_mul_field')->value = 'Test 1.1';
$this->storage
->save($entity);
/** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
$revision = $this->storage
->createRevision($entity
->addTranslation('it'));
$revision
->get('name')->value = 'Test 1.2 IT';
$this->storage
->save($revision);
$revision = $this->storage
->createRevision($revision
->getTranslation('en'), FALSE);
$revision
->get('non_mul_field')->value = 'Test 1.3';
$revision
->getTranslation('it')
->get('name')->value = 'Test 1.3 IT';
$violations = $revision
->validate();
$this
->assertCount(1, $violations);
$this
->assertEquals('Non-translatable fields can only be changed when updating the original language.', $violations[0]
->getMessage());
}
/**
* Tests that internal properties are preserved while creating a new revision.
*/
public function testInternalProperties() {
$entity = EntityTestMulRev::create();
$this
->doTestInternalProperties($entity);
$entity = EntityTestMulRev::create();
$entity
->save();
$this
->doTestInternalProperties($entity);
/** @var \Drupal\entity_test\Entity\EntityTestMulRev $translation */
$translation = EntityTestMulRev::create()
->addTranslation('it');
$translation
->save();
$this
->doTestInternalProperties($translation);
}
/**
* Checks that internal properties are preserved for the specified entity.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* An entity object.
*/
protected function doTestInternalProperties(ContentEntityInterface $entity) {
$this
->assertFalse($entity
->isValidationRequired());
$entity
->setValidationRequired(TRUE);
$this
->assertTrue($entity
->isValidationRequired());
$new_revision = $this->storage
->createRevision($entity);
$this
->assertTrue($new_revision
->isValidationRequired());
}
/**
* Tests that deleted translations are not accidentally restored.
*
* @covers ::createRevision
*/
public function testRemovedTranslations() {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = EntityTestMulRev::create([
'name' => 'Test 1.1 EN',
]);
$this->storage
->save($entity);
/** @var \Drupal\Core\Entity\ContentEntityInterface $it_revision */
$it_revision = $this->storage
->createRevision($entity
->addTranslation('it'));
$it_revision
->set('name', 'Test 1.2 IT');
$this->storage
->save($it_revision);
/** @var \Drupal\Core\Entity\ContentEntityInterface $en_revision */
$en_revision = $this->storage
->createRevision($it_revision
->getUntranslated(), FALSE);
$en_revision
->set('name', 'Test 1.3 EN');
$this->storage
->save($en_revision);
/** @var \Drupal\Core\Entity\ContentEntityInterface $en_revision */
$it_revision = $this->storage
->createRevision($it_revision);
$en_revision = $it_revision
->getUntranslated();
$en_revision
->removeTranslation('it');
$this->storage
->save($en_revision);
$revision_id = $this->storage
->getLatestTranslationAffectedRevisionId($entity
->id(), 'en');
$en_revision = $this->storage
->loadRevision($revision_id);
$en_revision = $this->storage
->createRevision($en_revision);
$en_revision
->set('name', 'Test 1.5 EN');
$this->storage
->save($en_revision);
$en_revision = $this->storage
->loadRevision($en_revision
->getRevisionId());
$this
->assertFalse($en_revision
->hasTranslation('it'));
}
/**
* Checks that the revision create hook works as expected.
*
* @covers ::createRevision
*/
public function testCreateRevisionHook() {
$entity = EntityTestMulRev::create();
$entity
->get('name')->value = 'revision_create_test_en';
$this->storage
->save($entity);
/** @var \Drupal\Core\Entity\ContentEntityInterface $translation */
$translation = $entity
->addTranslation('it');
$translation
->set('name', 'revision_create_test_it');
/** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
$revision = $this->storage
->createRevision($translation, FALSE, TRUE);
// Assert that the alter hook can alter the new revision.
$this
->assertEquals('revision_create_test_it_altered', $revision
->get('name')->value);
// Assert the data passed to the hook.
$data = $this->state
->get('entity_test.hooks');
$this
->assertEquals('revision_create_test_it', $data['entity_test_mulrev_revision_create']['entity']
->get('name')->value);
$this
->assertEquals('revision_create_test_it_altered', $data['entity_test_mulrev_revision_create']['new_revision']
->get('name')->value);
$this
->assertFalse($data['entity_test_mulrev_revision_create']['entity']
->isNewRevision());
$this
->assertTrue($data['entity_test_mulrev_revision_create']['new_revision']
->isNewRevision());
$this
->assertTrue($data['entity_test_mulrev_revision_create']['entity']
->isDefaultRevision());
$this
->assertFalse($data['entity_test_mulrev_revision_create']['new_revision']
->isDefaultRevision());
$this
->assertTrue($data['entity_test_mulrev_revision_create']['keep_untranslatable_fields']);
$this
->assertEquals('revision_create_test_it', $data['entity_revision_create']['entity']
->get('name')->value);
$this
->assertEquals('revision_create_test_it_altered', $data['entity_revision_create']['new_revision']
->get('name')->value);
$this
->assertFalse($data['entity_revision_create']['entity']
->isNewRevision());
$this
->assertTrue($data['entity_revision_create']['new_revision']
->isNewRevision());
$this
->assertTrue($data['entity_revision_create']['entity']
->isDefaultRevision());
$this
->assertFalse($data['entity_revision_create']['new_revision']
->isDefaultRevision());
$this
->assertTrue($data['entity_revision_create']['keep_untranslatable_fields']);
// Test again with different arguments.
$translation
->isDefaultRevision(FALSE);
$this->storage
->createRevision($translation);
$data = $this->state
->get('entity_test.hooks');
$this
->assertFalse($data['entity_revision_create']['entity']
->isNewRevision());
$this
->assertTrue($data['entity_revision_create']['new_revision']
->isNewRevision());
$this
->assertFalse($data['entity_revision_create']['entity']
->isDefaultRevision());
$this
->assertTrue($data['entity_revision_create']['new_revision']
->isDefaultRevision());
$this
->assertNull($data['entity_revision_create']['keep_untranslatable_fields']);
$this
->assertFalse($data['entity_test_mulrev_revision_create']['entity']
->isNewRevision());
$this
->assertTrue($data['entity_test_mulrev_revision_create']['new_revision']
->isNewRevision());
$this
->assertFalse($data['entity_test_mulrev_revision_create']['entity']
->isDefaultRevision());
$this
->assertTrue($data['entity_test_mulrev_revision_create']['new_revision']
->isDefaultRevision());
$this
->assertNull($data['entity_test_mulrev_revision_create']['keep_untranslatable_fields']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertContentTrait:: |
protected | property | The current raw content. | |
AssertContentTrait:: |
protected | property | The drupalSettings value from the current raw $content. | |
AssertContentTrait:: |
protected | property | The XML structure parsed from the current raw $content. | 1 |
AssertContentTrait:: |
protected | property | The plain-text content of raw $content (text nodes). | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertContentTrait:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href is not found in the main region. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page does not exist. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertContentTrait:: |
protected | function | Pass if the page title is not the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertContentTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertContentTrait:: |
protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | |
AssertContentTrait:: |
protected | function | Asserts themed output. | |
AssertContentTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
AssertContentTrait:: |
protected | function | Builds an XPath query. | |
AssertContentTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertContentTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
AssertContentTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertContentTrait:: |
protected | function | Gets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Gets the current raw content. | |
AssertContentTrait:: |
protected | function | Get the selected value from a select field. | |
AssertContentTrait:: |
protected | function | Retrieves the plain-text content from the current raw content. | |
AssertContentTrait:: |
protected | function | Get the current URL from the cURL handler. | 1 |
AssertContentTrait:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
AssertContentTrait:: |
protected | function | Removes all white-space between HTML tags from the raw content. | |
AssertContentTrait:: |
protected | function | Sets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Sets the raw content (e.g. HTML). | |
AssertContentTrait:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
DeprecatedServicePropertyTrait:: |
public | function | Allows to access deprecated/removed properties. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | property | The entity type bundle info service. | |
EntityDecoupledTranslationRevisionsTest:: |
public static | property |
Modules to enable. Overrides EntityKernelTestBase:: |
|
EntityDecoupledTranslationRevisionsTest:: |
protected | property | The previous revision identifiers for the various revision translations. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | property | The previous untranslatable field value. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | property | The current edit sequence step index. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | property | The current edit sequence step info. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | property | The entity storage. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | property | The translations of the test entity. | |
EntityDecoupledTranslationRevisionsTest:: |
public | function | Data provider for ::testDecoupledDefaultRevisions. | |
EntityDecoupledTranslationRevisionsTest:: |
public | function | Data provider for ::testUntranslatableFields. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | function | Saves a new revision of the test entity. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | function | Actually tests an edit step sequence. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | function | Checks that internal properties are preserved for the specified entity. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | function | Formats an assertion message. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | function | Generates a new label for the specified revision. | |
EntityDecoupledTranslationRevisionsTest:: |
protected | function |
Overrides EntityKernelTestBase:: |
|
EntityDecoupledTranslationRevisionsTest:: |
public | function | Checks that the revision create hook works as expected. | |
EntityDecoupledTranslationRevisionsTest:: |
public | function | Test decoupled default revisions. | |
EntityDecoupledTranslationRevisionsTest:: |
public | function | Tests that internal properties are preserved while creating a new revision. | |
EntityDecoupledTranslationRevisionsTest:: |
public | function | Checks that changes to multiple translations are handled correctly. | |
EntityDecoupledTranslationRevisionsTest:: |
public | function | Tests that deleted translations are not accidentally restored. | |
EntityDecoupledTranslationRevisionsTest:: |
public | function | Tests that untranslatable fields are handled correctly. | |
EntityKernelTestBase:: |
protected | property | The list of deprecated services. | |
EntityKernelTestBase:: |
protected | property | The entity type manager service. | 1 |
EntityKernelTestBase:: |
protected | property | A list of generated identifiers. | |
EntityKernelTestBase:: |
protected | property | The state service. | |
EntityKernelTestBase:: |
protected | function | Creates a user. | |
EntityKernelTestBase:: |
protected | function | Generates a random ID avoiding collisions. | |
EntityKernelTestBase:: |
protected | function | Returns the entity_test hook invocation info. | |
EntityKernelTestBase:: |
protected | function | Installs a module and refreshes services. | |
EntityKernelTestBase:: |
protected | function | Refresh services. | 1 |
EntityKernelTestBase:: |
protected | function | Reloads the given entity from the storage and returns it. | |
EntityKernelTestBase:: |
protected | function | Uninstalls a module and refreshes services. | |
KernelTestBase:: |
protected | property | Back up and restore any global variables that may be changed by tests. | |
KernelTestBase:: |
protected | property | Back up and restore static class properties that may be changed by tests. | |
KernelTestBase:: |
protected | property | Contains a few static class properties for performance. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | @todo Move into Config test base class. | 7 |
KernelTestBase:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. | |
KernelTestBase:: |
protected | property | The app root. | |
KernelTestBase:: |
protected | property | Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Set to TRUE to strict check all configuration saved. | 6 |
KernelTestBase:: |
protected | property | The virtual filesystem root directory. | |
KernelTestBase:: |
protected | function | 1 | |
KernelTestBase:: |
protected | function | Bootstraps a basic test environment. | |
KernelTestBase:: |
private | function | Bootstraps a kernel for a test. | |
KernelTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
KernelTestBase:: |
protected | function | Disables modules for this test. | |
KernelTestBase:: |
protected | function | Enables modules for this test. | |
KernelTestBase:: |
protected | function | Gets the config schema exclusions for this test. | |
KernelTestBase:: |
protected | function | Returns the Database connection info to be used for this test. | 1 |
KernelTestBase:: |
public | function | ||
KernelTestBase:: |
private | function | Returns Extension objects for $modules to enable. | |
KernelTestBase:: |
private static | function | Returns the modules to enable for this test. | |
KernelTestBase:: |
protected | function | Initializes the FileCache component. | |
KernelTestBase:: |
protected | function | Installs default configuration for a given list of modules. | |
KernelTestBase:: |
protected | function | Installs the storage schema for a specific entity type. | |
KernelTestBase:: |
protected | function | Installs database tables from a module schema definition. | |
KernelTestBase:: |
protected | function | Returns whether the current test method is running in a separate process. | |
KernelTestBase:: |
protected | function | ||
KernelTestBase:: |
public | function |
Registers test-specific services. Overrides ServiceProviderInterface:: |
26 |
KernelTestBase:: |
protected | function | Renders a render array. | 1 |
KernelTestBase:: |
protected | function | Sets the install profile and rebuilds the container to update it. | |
KernelTestBase:: |
protected | function | Sets an in-memory Settings variable. | |
KernelTestBase:: |
public static | function | 1 | |
KernelTestBase:: |
protected | function | Sets up the filesystem, so things like the file directory. | 2 |
KernelTestBase:: |
protected | function | Stops test execution. | |
KernelTestBase:: |
protected | function | 6 | |
KernelTestBase:: |
public | function | @after | |
KernelTestBase:: |
protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |
KernelTestBase:: |
public | function | Prevents serializing any properties. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. Aliased as: drupalCheckPermissions | |
UserCreationTrait:: |
protected | function | Creates an administrative role. Aliased as: drupalCreateAdminRole | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. Aliased as: drupalCreateRole | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. Aliased as: drupalCreateUser | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. Aliased as: drupalGrantPermissions | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. Aliased as: drupalSetCurrentUser | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. Aliased as: drupalSetUpCurrentUser |