X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fentity_reference_revisions%2Fsrc%2FTests%2FEntityReferenceRevisionsAutocompleteTest.php;fp=web%2Fmodules%2Fcontrib%2Fentity_reference_revisions%2Fsrc%2FTests%2FEntityReferenceRevisionsAutocompleteTest.php;h=0000000000000000000000000000000000000000;hb=059867c3f96750652c80f39e44c442a58c2549ee;hp=a80c615e59d598b523d8a59ae207bb3f1d9a9391;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2;p=yaffs-website diff --git a/web/modules/contrib/entity_reference_revisions/src/Tests/EntityReferenceRevisionsAutocompleteTest.php b/web/modules/contrib/entity_reference_revisions/src/Tests/EntityReferenceRevisionsAutocompleteTest.php deleted file mode 100644 index a80c615e5..000000000 --- a/web/modules/contrib/entity_reference_revisions/src/Tests/EntityReferenceRevisionsAutocompleteTest.php +++ /dev/null @@ -1,147 +0,0 @@ -drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); - // Place the breadcrumb, tested in fieldUIAddNewField(). - $this->drupalPlaceBlock('system_breadcrumb_block'); - } - - /** - * Test for autocomplete processing. - * - * Tests that processing does not crash when the entity types of the - * referenced entity and of the entity the field is attached to are different. - */ - public function testEntityReferenceRevisionsAutocompleteProcessing() { - $admin_user = $this->drupalCreateUser(array( - 'administer site configuration', - 'administer nodes', - 'administer blocks', - 'create article content', - 'administer content types', - 'administer node fields', - 'administer node display', - 'administer node form display', - 'edit any article content', - )); - $this->drupalLogin($admin_user); - - // Create a custom block content bundle. - $this->createBlockContentType(array('type' => 'customblockcontent', 'name' => 'Custom Block Content')); - - // Create entity reference revisions field attached to article. - static::fieldUIAddNewField( - 'admin/structure/types/manage/article', - 'entity_reference_revisions', - 'Entity reference revisions', - 'entity_reference_revisions', - array('settings[target_type]' => 'block_content', 'cardinality' => '-1'), - array('settings[handler_settings][target_bundles][customblockcontent]' => TRUE) - ); - - // Create custom block. - $block_label = $this->randomMachineName(); - $block_content = $this->randomString(); - $edit = array( - 'info[0][value]' => $block_label, - 'body[0][value]' => $block_content, - ); - $this->drupalPostForm('block/add', $edit, t('Save')); - $block = $this->drupalGetBlockByInfo($block_label); - - // Create an article. - $title = $this->randomMachineName(); - $edit = array( - 'title[0][value]' => $title, - 'body[0][value]' => 'Revision 1', - 'field_entity_reference_revisions[0][target_id]' => $block_label . ' (' . $block->id() . ')', - ); - $this->drupalPostNodeForm('node/add/article', $edit, t('Save and publish')); - $this->assertText($title); - $this->assertText(Html::escape($block_content)); - - // Check if the block content is not deleted since there is no composite - // relationship. - $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); - $node = Node::load($node->id()); - $node->delete(); - $this->assertNotNull(BlockContent::load($block->id())); - } - - /** - * Get a custom block from the database based on its title. - * - * @param $info - * A block title, usually generated by $this->randomMachineName(). - * @param $reset - * (optional) Whether to reset the entity cache. - * - * @return \Drupal\block\BlockInterface - * A block entity matching $info. - */ - function drupalGetBlockByInfo($info, $reset = FALSE) { - if ($reset) { - \Drupal::entityTypeManager()->getStorage('block_content')->resetCache(); - } - $blocks = \Drupal::entityTypeManager()->getStorage('block_content')->loadByProperties(array('info' => $info)); - // Get the first block returned from the database. - $returned_block = reset($blocks); - return $returned_block; - } - - /** - * Create a block_content bundle. - * - * @param $parameters - * An assoc array with name (human readable) and type (bundle machine name) - * as keys. - */ - function createBlockContentType($parameters) { - $label = $parameters['name']; - $machine_name = $parameters['type']; - $edit = array( - 'label' => $label, - 'id' => $machine_name, - 'revision' => TRUE, - ); - $this->drupalPostForm('admin/structure/block/block-content/types/add', $edit, t('Save')); - $this->assertText($label); - } - -}