getNewEntityValues example

$this->doTestTranslationChanged();
    $this->doTestChangedTimeAfterSaveWithoutChanges();
    $this->doTestTranslationDeletion();
  }

  /** * Tests the basic translation workflow. */
  protected function doTestBasicTranslation() {
    // Create a new test entity with original values in the default language.     $default_langcode = $this->langcodes[0];
    $values[$default_langcode] = $this->getNewEntityValues($default_langcode);
    // Create the entity with the editor as owner, so that afterwards a new     // translation is created by the translator and the translation author is     // tested.     $this->drupalLogin($this->editor);
    $this->entityId = $this->createEntity($values[$default_langcode]$default_langcode);
    $this->drupalLogin($this->translator);
    $storage = $this->container->get('entity_type.manager')
      ->getStorage($this->entityTypeId);
    $storage->resetCache([$this->entityId]);
    $entity = $storage->load($this->entityId);
    $this->assertNotEmpty($entity, 'Entity found in the database.');
    
'access block library',
      'create basic block content',
      'edit any basic block content',
      'delete any basic block content',
    ]);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    return ['info' => mb_strtolower($this->randomMachineName())] + parent::getNewEntityValues($langcode);
  }

  /** * Returns an edit array containing the values to be posted. */
  protected function getEditValues($values$langcode$new = FALSE) {
    $edit = parent::getEditValues($values$langcode$new);
    foreach ($edit as $property => $value) {
      if ($property == 'info') {
        $edit['info[0][value]'] = $value;
        unset($edit[$property]);
      }
/** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['administer taxonomy']);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    return ['name' => $this->randomMachineName()] + parent::getNewEntityValues($langcode);
  }

  /** * Returns an edit array containing the values to be posted. */
  protected function getEditValues($values$langcode$new = FALSE) {
    $edit = parent::getEditValues($values$langcode$new);

    // To be able to post values for the configurable base fields (name,     // description) have to be suffixed with [0][value].     foreach ($edit as $property => $value) {
      

  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['administer users']);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    // User name is not translatable hence we use a fixed value.     return ['name' => $this->name] + parent::getNewEntityValues($langcode);
  }

  /** * {@inheritdoc} */
  protected function doTestTranslationEdit() {
    $storage = $this->container->get('entity_type.manager')
      ->getStorage($this->entityTypeId);
    $storage->resetCache([$this->entityId]);
    $entity = $storage->load($this->entityId);
    $languages = $this->container->get('language_manager')->getLanguages();

    

  protected function createEntity($values$langcode$bundle_name = NULL) {
    $values['link']['uri'] = 'internal:/user';
    return parent::createEntity($values$langcode$bundle_name);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    return ['title' => [['value' => $this->randomMachineName()]]] + parent::getNewEntityValues($langcode);
  }

  protected function doTestBasicTranslation() {
    parent::doTestBasicTranslation();

    $storage = $this->container->get('entity_type.manager')
      ->getStorage($this->entityTypeId);
    $storage->resetCache([$this->entityId]);
    $entity = $storage->load($this->entityId);
    foreach ($this->langcodes as $langcode) {
      if ($entity->hasTranslation($langcode)) {
        
return parent::createEntity($values$langcode$comment_type);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    // Comment subject is not translatable hence we use a fixed value.     return [
      'subject' => [['value' => $this->subject]],
      'comment_body' => [['value' => $this->randomMachineName(16)]],
    ] + parent::getNewEntityValues($langcode);
  }

  /** * {@inheritdoc} */
  protected function doTestPublishedStatus() {
    $entity_type_manager = \Drupal::entityTypeManager();
    $storage = $entity_type_manager->getStorage($this->entityTypeId);

    $storage->resetCache();
    $entity = $storage->load($this->entityId);

    
'administer languages',
    ]);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    return [
      'name' => [['value' => $this->randomMachineName()]],
      'field_media_test' => [['value' => $this->randomMachineName()]],
    ] + parent::getNewEntityValues($langcode);
  }

}
/** * {@inheritdoc} */
  protected function getAdministratorPermissions() {
    return array_merge(parent::getAdministratorPermissions()['access administration pages', 'administer content types', 'administer node fields', 'access content overview', 'bypass node access', 'administer languages', 'administer themes', 'view the administration theme']);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    return ['title' => [['value' => $this->randomMachineName()]]] + parent::getNewEntityValues($langcode);
  }

  /** * {@inheritdoc} */
  protected function doTestPublishedStatus() {
    $storage = $this->container->get('entity_type.manager')
      ->getStorage($this->entityTypeId);
    $storage->resetCache([$this->entityId]);
    $entity = $storage->load($this->entityId);
    $languages = $this->container->get('language_manager')->getLanguages();

    
Home | Imprint | This part of the site doesn't use cookies.