Issue #3405085 by quietone, smustgrave: Fix test performance of \Drupal\Tests\content_translation\Functional\ContentTranslationStandardFieldsTest
parent
594ab1aaf6
commit
30dbdff287
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
namespace Drupal\Tests\content_translation\Functional;
|
namespace Drupal\Tests\content_translation\Functional;
|
||||||
|
|
||||||
|
use Drupal\block_content\Entity\BlockContentType;
|
||||||
|
use Drupal\comment\Entity\CommentType;
|
||||||
use Drupal\Tests\BrowserTestBase;
|
use Drupal\Tests\BrowserTestBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the Content translation settings using the standard profile.
|
* Tests the Content translation settings.
|
||||||
*
|
*
|
||||||
* @group content_translation
|
* @group content_translation
|
||||||
*/
|
*/
|
||||||
|
@ -22,13 +24,17 @@ class ContentTranslationStandardFieldsTest extends BrowserTestBase {
|
||||||
'node',
|
'node',
|
||||||
'comment',
|
'comment',
|
||||||
'field_ui',
|
'field_ui',
|
||||||
'entity_test',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected $profile = 'standard';
|
protected $defaultTheme = 'stark';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $profile = 'testing';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -53,6 +59,90 @@ class ContentTranslationStandardFieldsTest extends BrowserTestBase {
|
||||||
* Tests that translatable fields are being rendered.
|
* Tests that translatable fields are being rendered.
|
||||||
*/
|
*/
|
||||||
public function testFieldTranslatableArticle() {
|
public function testFieldTranslatableArticle() {
|
||||||
|
// Install block and field modules.
|
||||||
|
\Drupal::service('module_installer')->install(
|
||||||
|
[
|
||||||
|
'block',
|
||||||
|
'block_content',
|
||||||
|
'filter',
|
||||||
|
'image',
|
||||||
|
'text',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Create a basic block type with a body field.
|
||||||
|
$bundle = BlockContentType::create([
|
||||||
|
'id' => 'basic',
|
||||||
|
'label' => 'Basic',
|
||||||
|
'revision' => FALSE,
|
||||||
|
]);
|
||||||
|
$bundle->save();
|
||||||
|
block_content_add_body_field($bundle->id());
|
||||||
|
|
||||||
|
// Create a comment type with a body field.
|
||||||
|
$bundle = CommentType::create([
|
||||||
|
'id' => 'comment',
|
||||||
|
'label' => 'Comment',
|
||||||
|
'target_entity_type_id' => 'node',
|
||||||
|
]);
|
||||||
|
$bundle->save();
|
||||||
|
\Drupal::service('comment.manager')->addBodyField('comment');
|
||||||
|
|
||||||
|
// Create the article content type and add a comment, image and tag field.
|
||||||
|
$this->drupalCreateContentType(['type' => 'article', 'title' => 'Article']);
|
||||||
|
|
||||||
|
$entity_type_manager = \Drupal::entityTypeManager();
|
||||||
|
$entity_type_manager->getStorage('field_storage_config')->create([
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'field_name' => 'comment',
|
||||||
|
'type' => 'text',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$entity_type_manager->getStorage('field_config')->create([
|
||||||
|
'label' => 'Comments',
|
||||||
|
'field_name' => 'comment',
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'bundle' => 'article',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$entity_type_manager->getStorage('field_storage_config')->create([
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'field_name' => 'field_image',
|
||||||
|
'type' => 'image',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$entity_type_manager->getStorage('field_config')->create([
|
||||||
|
'label' => 'Image',
|
||||||
|
'field_name' => 'field_image',
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'bundle' => 'article',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$entity_type_manager->getStorage('field_storage_config')->create([
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'field_name' => 'field_tags',
|
||||||
|
'type' => 'text',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$entity_type_manager->getStorage('field_config')->create([
|
||||||
|
'label' => 'Tags',
|
||||||
|
'field_name' => 'field_tags',
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'bundle' => 'article',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$entity_type_manager->getStorage('field_storage_config')->create([
|
||||||
|
'entity_type' => 'user',
|
||||||
|
'field_name' => 'user_picture',
|
||||||
|
'type' => 'image',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
// Add a user picture field to the user entity.
|
||||||
|
$entity_type_manager->getStorage('field_config')->create([
|
||||||
|
'label' => 'Tags',
|
||||||
|
'field_name' => 'user_picture',
|
||||||
|
'entity_type' => 'user',
|
||||||
|
'bundle' => 'user',
|
||||||
|
])->save();
|
||||||
|
|
||||||
$path = 'admin/config/regional/content-language';
|
$path = 'admin/config/regional/content-language';
|
||||||
$this->drupalGet($path);
|
$this->drupalGet($path);
|
||||||
|
|
Loading…
Reference in New Issue