label example

->save();
    // Create a display for the full view mode.     $display_repository->getViewDisplay('entity_test', 'entity_test', 'full')
      ->setComponent($field_name[
        'type' => 'boolean',
      ])
      ->save();

    // Display creation form.     $this->drupalGet('entity_test/add');
    $this->assertSession()->fieldValueEquals("{$field_name}[value]", '');
    $this->assertSession()->pageTextContains($this->field->label());
    $this->assertSession()->responseNotContains($on);

    // Submit and ensure it is accepted.     $edit = [
      "{$field_name}[value]" => 1,
    ];
    $this->submitForm($edit, 'Save');
    preg_match('|entity_test/manage/(\d+)|', $this->getUrl()$match);
    $id = $match[1];
    $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');

    
$container->get('datetime.time')
    );
  }

  /** * {@inheritdoc} */
  public function form(array $form, FormStateInterface $form_state) {
    $workspace = $this->entity;

    if ($this->operation == 'edit') {
      $form['#title'] = $this->t('Edit workspace %label', ['%label' => $workspace->label()]);
    }
    $form['label'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Label'),
      '#maxlength' => 255,
      '#default_value' => $workspace->label(),
      '#required' => TRUE,
    ];

    $form['id'] = [
      '#type' => 'machine_name',
      

  public function testTermArgumentTransformation($name) {
    /** @var \Drupal\taxonomy\TermInterface $term */
    $term = $this->createTerm(['name' => $name]);

    /** @var \Drupal\views\ViewExecutable $view */
    $view = Views::getView('test_argument_transform_term');
    $view->initHandlers();

    /** @var string $hyphenated_term */
    $hyphenated_term = str_replace(' ', '-', $term->label());
    $this->assertTrue($view->argument['tid']->setArgument($hyphenated_term));
    // Assert hyphens are converted back to spaces.     $this->assertEquals($term->label()$view->argument['tid']->argument);
  }

  /** * Provides data for testTermArgumentTransformation(). * * @return array[] * Test data. */
  
$this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains("The machine-readable name is already in use. It must be unique.");

    // Test renaming a role.     $role_name = '456';
    $edit = ['label' => $role_name];
    $this->drupalGet("admin/people/roles/manage/{$role->id()}");
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains("Role {$role_name} has been updated.");
    \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]);
    $new_role = Role::load($role->id());
    $this->assertEquals($role_name$new_role->label(), 'The role name has been successfully changed.');

    // Test deleting a role.     $this->drupalGet("admin/people/roles/manage/{$role->id()}");
    $this->clickLink('Delete');
    $this->submitForm([], 'Delete');
    $this->assertSession()->pageTextContains("Role {$role_name} has been deleted.");
    $this->assertSession()->linkByHrefNotExists("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.');
    \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]);
    $this->assertNull(Role::load($role->id()), 'A deleted role can no longer be loaded.');

    // Make sure that the system-defined roles can be edited via the user
/** * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration. */
  public function testVocabularyFieldInstance() {
    $this->executeMigration('d6_vocabulary_field_instance');

    // Test that the field exists. Tags has a multilingual option of 'None'.     $field_id = 'node.article.field_tags';
    $field = FieldConfig::load($field_id);
    $this->assertSame($field_id$field->id(), 'Field instance exists on article bundle.');
    $this->assertSame('Tags', $field->label());
    $this->assertTrue($field->isRequired(), 'Field is required');
    $this->assertFalse($field->isTranslatable());
    $this->assertTargetBundles($field_id['tags' => 'tags']);

    // Test the page bundle as well. Tags has a multilingual option of 'None'.     $field_id = 'node.page.field_tags';
    $field = FieldConfig::load($field_id);
    $this->assertSame($field_id$field->id(), 'Field instance exists on page bundle.');
    $this->assertSame('Tags', $field->label());
    $this->assertTrue($field->isRequired(), 'Field is required');
    $this->assertFalse($field->isTranslatable());

    

  public function forumIndex() {
    $vocabulary = $this->vocabularyStorage->load($this->config('forum.settings')->get('vocabulary'));
    $index = $this->forumManager->getIndex();
    $build = $this->build($index->forums, $index);
    if (empty($index->forums)) {
      // Root of empty forum.       $build['#title'] = $this->t('No forums defined');
    }
    else {
      // Set the page title to forum's vocabulary name.       $build['#title'] = $vocabulary->label();
      $this->renderer->addCacheableDependency($build$vocabulary);
    }
    return $build;
  }

  /** * Returns a renderable forum index page array. * * @param array $forums * A list of forums. * @param \Drupal\taxonomy\TermInterface $term * The taxonomy term of the forum. * @param array $topics * The topics of this forum. * @param array $parents * The parent forums in relation this forum. * @param array $header * Array of header cells. * * @return array * A render array. */
if ($status !== 0) {
      return $status;
    }

    // Sort by weight.     $weight = $a->getWeight() - $b->getWeight();
    if ($weight) {
      return $weight;
    }

    // Sort by label.     return strcmp($a->label()$b->label());
  }

  /** * {@inheritdoc} */
  public function calculateDependencies() {
    parent::calculateDependencies();
    $this->addDependency('theme', $this->theme);
    return $this;
  }

  
public function testMenuLinkContentDeleteForm() {
    // Add new menu item.     $this->drupalGet('admin/structure/menu/manage/admin/add');
    $this->submitForm([
      'title[0][value]' => 'Front page',
      'link[0][uri]' => '<front>',
    ], 'Save');
    $this->assertSession()->pageTextContains('The menu link has been saved.');

    $menu_link = MenuLinkContent::load(1);
    $this->drupalGet($menu_link->toUrl('delete-form'));
    $this->assertSession()->pageTextContains("Are you sure you want to delete the custom menu link {$menu_link->label()}?");
    $this->assertSession()->linkExists('Cancel');
    // Make sure cancel link points to link edit     $this->assertSession()->linkByHrefExists($menu_link->toUrl('edit-form')->toString());

    \Drupal::service('module_installer')->install(['menu_ui']);

    // Make sure cancel URL points to menu_ui route now.     $this->drupalGet($menu_link->toUrl('delete-form'));
    $menu = Menu::load($menu_link->getMenuName());
    $this->assertSession()->linkByHrefExists($menu->toUrl('edit-form')->toString());
    $this->submitForm([], 'Delete');
    
// First update the index. This does the initial processing.     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
  }

  /** * Tests advanced search by node type. */
  public function testNodeType() {
    // Verify some properties of the node that was created.     $this->assertSame('page', $this->node->getType(), 'Node type is Basic page.');
    $dummy_title = 'Lorem ipsum';
    $this->assertNotEquals($dummy_title$this->node->label(), "Dummy title doesn't equal node title.");

    // Search for the dummy title with a GET query.     $this->drupalGet('search/node', ['query' => ['keys' => $dummy_title]]);
    $this->assertSession()->pageTextNotContains($this->node->label());

    // Search for the title of the node with a GET query.     $this->drupalGet('search/node', ['query' => ['keys' => $this->node->label()]]);
    $this->assertSession()->pageTextContains($this->node->label());

    // Search for the title of the node with a POST query.     $edit = ['or' => $this->node->label()];
    
->fetchCol();
      $roles = [RoleInterface::AUTHENTICATED_ID];
      $id_map = $this->getMigration('d6_user_role')->getIdMap();
      foreach ($rids as $rid) {
        $role = $id_map->lookupDestinationIds([$rid])[0];
        $roles[] = reset($role);
      }

      /** @var \Drupal\user\UserInterface $user */
      $user = User::load($source->uid);
      $this->assertSame($source->uid, $user->id());
      $this->assertSame($source->name, $user->label());
      $this->assertSame($source->mail, $user->getEmail());
      $this->assertSame($source->created, $user->getCreatedTime());
      $this->assertSame($source->access, $user->getLastAccessedTime());
      $this->assertSame($source->login, $user->getLastLoginTime());
      $is_blocked = $source->status == 0;
      $this->assertSame($is_blocked$user->isBlocked());
      $expected_timezone_name = $source->timezone_name ?: $this->config('system.date')->get('timezone.default');
      $this->assertSame($expected_timezone_name$user->getTimeZone());
      $this->assertSame($source->init, $user->getInitialEmail());
      $this->assertSame($roles$user->getRoles());

      

  }

  /** * {@inheritdoc} */
  public function form(array $form, FormStateInterface $form_state) {

    $form['label'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Image style name'),
      '#default_value' => $this->entity->label(),
      '#required' => TRUE,
    ];
    $form['name'] = [
      '#type' => 'machine_name',
      '#machine_name' => [
        'exists' => [$this->imageStyleStorage, 'load'],
      ],
      '#default_value' => $this->entity->id(),
      '#required' => TRUE,
    ];

    
$storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
        return $storage->loadRevision($storage->getLatestRevisionId($entity->id()));
      });

      // If the latest revision of the entity is tracked in a workspace, it can       // only be edited in that workspace or one of its descendants.       if ($latest_revision_workspace = $latest_revision->workspace->entity) {
        $descendants_and_self = $this->workspaceRepository->getDescendantsAndSelf($latest_revision_workspace->id());

        if (!$active_workspace || !in_array($active_workspace->id()$descendants_and_self, TRUE)) {
          $this->context->buildViolation($constraint->message)
            ->setParameter('%label', $latest_revision_workspace->label())
            ->addViolation();
        }
      }
    }
  }

}

  protected function assertEntity(string $id, string $language, string $label, string $description): void {
    $navigation_menu = Menu::load($id);
    $this->assertSame($id$navigation_menu->id());
    $this->assertSame($language$navigation_menu->language()->getId());
    $this->assertSame($label$navigation_menu->label());
    $this->assertSame($description$navigation_menu->getDescription());
  }

  /** * Tests the Drupal 7 menu to Drupal 8 migration. */
  public function testMenu() {
    $this->assertEntity('main', 'und', 'Main menu', 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.');
    $this->assertEntity('admin', 'und', 'Management', 'The <em>Management</em> menu contains links for administrative tasks.');
    $this->assertEntity('menu-test-menu', 'und', 'Test Menu', 'Test menu description.');
    $this->assertEntity('tools', 'und', 'Navigation', 'The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.');
    
/** * {@inheritdoc} */
  public function getProvider() {
    return 'field';
  }

  /** * {@inheritdoc} */
  public function getLabel() {
    return $this->label();
  }

  /** * {@inheritdoc} */
  public function getDescription() {
    return NULL;
  }

  /** * {@inheritdoc} */
$entities = array_replace($workspace_tree$storage->loadMultiple());

    // If we need to restrict the list of workspaces by searching only a part of     // their label ($match) or by a number of results ($limit), the workspace     // tree would be mangled because it wouldn't contain all the tree items.     if ($match || $limit) {
      $options = parent::getReferenceableEntities($match$match_operator$limit);
    }
    else {
      $options = [];
      foreach ($entities as $entity) {
        $options[$entity->bundle()][$entity->id()] = str_repeat('-', $workspace_tree[$entity->id()]['depth']) . Html::escape($this->entityRepository->getTranslationFromContext($entity)->label());
      }
    }

    $restricted_access_entities = [];
    foreach ($options as $bundle => $bundle_options) {
      foreach (array_keys($bundle_options) as $id) {
        // If a user can not view a workspace, we need to prevent them from         // referencing that workspace as well as its descendants.         if (in_array($id$restricted_access_entities) || !$entities[$id]->access('view', $this->currentUser)) {
          $restricted_access_entities += $workspace_tree[$id]['descendants'];
          unset($options[$bundle][$id]);
        }
Home | Imprint | This part of the site doesn't use cookies.