.../QuickEditIntegrationTest.php | 90 +++++++--------------- 1 file changed, 28 insertions(+), 62 deletions(-) diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php index e212857d7c..52d645f0f8 100644 --- a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php +++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php @@ -7,7 +7,6 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\editor\Entity\Editor; use Drupal\filter\Entity\FilterFormat; -use Drupal\node\NodeInterface; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; use Drupal\Tests\field\Traits\EntityReferenceTestTrait; @@ -93,14 +92,6 @@ protected function setUp() { ->setComponent($field_name, ['type' => 'entity_reference_label']) ->save(); - $block_content_type = BlockContentType::create([ - 'id' => 'basic', - 'label' => 'basic', - 'revision' => FALSE, - ]); - $block_content_type->save(); - block_content_add_body_field($block_content_type->id()); - $this->drupalPlaceBlock('page_title_block'); $this->drupalPlaceBlock('system_main_block'); @@ -123,17 +114,24 @@ protected function setUp() { * Tests if an article node can be in-place edited with Quick Edit. */ public function testArticleNode() { - $node = $this->createNodeWithTerm(); - $this->doTestArticle($node); - } + $term = Term::create([ + 'name' => 'foo', + 'vid' => 'tags', + ]); + $term->save(); + + $node = $this->drupalCreateNode([ + 'type' => 'article', + 'title' => t('My Test Node'), + 'body' => [ + 'value' => '

Hello world!

I do not know what to say…

I wish I were eloquent.

', + 'format' => 'some_format', + ], + 'field_tags' => [ + ['target_id' => $term->id()], + ], + ]); - /** - * Tests an article with Quick Edit. - * - * @param \Drupal\node\NodeInterface $node - * The node. - */ - protected function doTestArticle(NodeInterface $node) { $this->drupalGet('node/' . $node->id()); // Initial state. @@ -166,7 +164,7 @@ protected function doTestArticle(NodeInterface $node) { $assert_session = $this->assertSession(); // Click the title field. - $this->click('[data-quickedit-field-id="' . $this->getQuickEditFieldId('node/1/title/en/full') . '"].quickedit-candidate'); + $this->click('[data-quickedit-field-id="node/1/title/en/full"].quickedit-candidate'); $assert_session->waitForElement('css', '.quickedit-toolbar-field div[id*="title"]'); $this->assertQuickEditEntityToolbar((string) $node->label(), 'Title'); $this->assertEntityInstanceFieldStates('node', 1, 0, [ @@ -181,7 +179,7 @@ protected function doTestArticle(NodeInterface $node) { ]); // Append something to the title. - $this->typeInPlainTextEditor('[data-quickedit-field-id="' . $this->getQuickEditFieldId('node/1/title/en/full') . '"].quickedit-candidate', ' Llamas are awesome!'); + $this->typeInPlainTextEditor('[data-quickedit-field-id="node/1/title/en/full"].quickedit-candidate', ' Llamas are awesome!'); $this->awaitEntityInstanceFieldState('node', 1, 0, 'title', 'en', 'changed'); $this->assertEntityInstanceFieldStates('node', 1, 0, [ 'node/1/title/en/full' => 'changed', @@ -218,7 +216,7 @@ protected function doTestArticle(NodeInterface $node) { // Click the tags field. hold_test_response(TRUE); - $this->click('[data-quickedit-field-id="' . $this->getQuickEditFieldId('node/1/field_tags/en/full') . '"]'); + $this->click('[data-quickedit-field-id="node/1/field_tags/en/full"]'); $assert_session->waitForElement('css', '.quickedit-toolbar-field div[id*="tags"]'); $this->assertQuickEditEntityToolbar((string) $node->label(), 'Tags'); $this->assertEntityInstanceFieldStates('node', 1, 0, [ @@ -286,6 +284,14 @@ protected function doTestArticle(NodeInterface $node) { * Tests if a custom can be in-place edited with Quick Edit. */ public function testCustomBlock() { + $block_content_type = BlockContentType::create([ + 'id' => 'basic', + 'label' => 'basic', + 'revision' => FALSE, + ]); + $block_content_type->save(); + block_content_add_body_field($block_content_type->id()); + $block_content = BlockContent::create([ 'info' => 'Llama', 'type' => 'basic', @@ -334,44 +340,4 @@ public function testCustomBlock() { $this->assertSession()->elementExists('css', '#quickedit-entity-toolbar .quickedit-toolgroup.wysiwyg-main > .cke_chrome .cke_top[role="presentation"] .cke_toolbar[role="toolbar"] .cke_toolgroup[role="presentation"] > .cke_button[title~="Bold"][role="button"]'); } - /** - * Create a node with a term reference for testing. - * - * @return \Drupal\node\NodeInterface - * The created node. - */ - protected function createNodeWithTerm() { - $term = Term::create([ - 'name' => 'foo', - 'vid' => 'tags', - ]); - $term->save(); - - $node = $this->drupalCreateNode([ - 'type' => 'article', - 'title' => t('My Test Node'), - 'body' => [ - 'value' => '

Hello world!

I do not know what to say…

I wish I were eloquent.

', - 'format' => 'some_format', - ], - 'field_tags' => [ - ['target_id' => $term->id()], - ], - ]); - return $node; - } - - /** - * Gets the Quick Edit field ID attribute value. - * - * @param string $original_field_id - * The original field ID. - * - * @return string - * The current field ID. - */ - protected function getQuickEditFieldId($original_field_id) { - return $original_field_id; - } - }