Chris@0: adminUser = $this->drupalCreateUser(['administer content types', 'administer node fields', 'administer node display']); Chris@0: $this->drupalLogin($this->adminUser); Chris@0: $this->drupalPlaceBlock('system_breadcrumb_block'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests the link field UI. Chris@0: */ Chris@0: public function testFieldUI() { Chris@0: // Add a content type. Chris@0: $type = $this->drupalCreateContentType(); Chris@0: $type_path = 'admin/structure/types/manage/' . $type->id(); Chris@0: $add_path = 'node/add/' . $type->id(); Chris@0: Chris@0: // Add a link field to the newly-created type. It defaults to allowing both Chris@0: // internal and external links. Chris@0: $label = $this->randomMachineName(); Chris@0: $field_name = Unicode::strtolower($label); Chris@0: $this->fieldUIAddNewField($type_path, $field_name, $label, 'link'); Chris@0: Chris@0: // Load the formatter page to check that the settings summary does not Chris@0: // generate warnings. Chris@0: // @todo Mess with the formatter settings a bit here. Chris@0: $this->drupalGet("$type_path/display"); Chris@0: $this->assertText(t('Link text trimmed to @limit characters', ['@limit' => 80])); Chris@0: Chris@0: // Test the help text displays when the link field allows both internal and Chris@0: // external links. Chris@0: $this->drupalLogin($this->drupalCreateUser(['create ' . $type->id() . ' content'])); Chris@0: $this->drupalGet($add_path); Chris@0: $this->assertRaw('You can also enter an internal path such as /node/add or an external URL such as http://example.com.'); Chris@0: Chris@0: // Log in an admin to set up the next content type. Chris@0: $this->drupalLogin($this->adminUser); Chris@0: Chris@0: // Add a different content type. Chris@0: $type = $this->drupalCreateContentType(); Chris@0: $type_path = 'admin/structure/types/manage/' . $type->id(); Chris@0: $add_path = 'node/add/' . $type->id(); Chris@0: Chris@0: // Add a link field to the newly-created type. Specify it must allow Chris@0: // external only links. Chris@0: $label = $this->randomMachineName(); Chris@0: $field_name = Unicode::strtolower($label); Chris@0: $field_edit = ['settings[link_type]' => LinkItemInterface::LINK_EXTERNAL]; Chris@0: $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', [], $field_edit); Chris@0: Chris@0: // Test the help text displays when link allows only external links. Chris@0: $this->drupalLogin($this->drupalCreateUser(['create ' . $type->id() . ' content'])); Chris@0: $this->drupalGet($add_path); Chris@0: $this->assertRaw('This must be an external URL such as http://example.com.'); Chris@0: } Chris@0: Chris@0: }