Skip to content
Snippets Groups Projects
Verified Commit 796cc268 authored by quietone's avatar quietone
Browse files

Issue #3385845 by shalini_jha, smustgrave: PrivateFileOnTranslatedEntityTest...

Issue #3385845 by shalini_jha, smustgrave: PrivateFileOnTranslatedEntityTest should use API to set up language

(cherry picked from commit 6bea4525)
parent c140cc18
No related branches found
No related tags found
9 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...
Pipeline #99877 passed
Pipeline: drupal

#99890

    Pipeline: drupal

    #99888

      Pipeline: drupal

      #99886

        +1
        ...@@ -79,11 +79,15 @@ public function testPrivateLanguageFile() { ...@@ -79,11 +79,15 @@ public function testPrivateLanguageFile() {
        $default_language_node = $this->drupalCreateNode(['type' => 'page']); $default_language_node = $this->drupalCreateNode(['type' => 'page']);
        // Edit the node to upload a file. // Edit the node to upload a file.
        $edit = []; $file = File::create(
        $name = 'files[' . $this->fieldName . '_0]'; [
        $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[0]->uri); 'uri' => $this->drupalGetTestFiles('text')[0]->uri,
        $this->drupalGet('node/' . $default_language_node->id() . '/edit'); ]
        $this->submitForm($edit, 'Save'); );
        $file->save();
        $default_language_node->set($this->fieldName, $file->id());
        $default_language_node->save();
        $last_fid_prior = $this->getLastFileId(); $last_fid_prior = $this->getLastFileId();
        // Languages are cached on many levels, and we need to clear those caches. // Languages are cached on many levels, and we need to clear those caches.
        ...@@ -97,18 +101,31 @@ public function testPrivateLanguageFile() { ...@@ -97,18 +101,31 @@ public function testPrivateLanguageFile() {
        $this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
        // Translate the node into French. // Translate the node into French.
        $this->drupalGet('node/' . $default_language_node->id() . '/translations'); $node->addTranslation(
        $this->clickLink('Add'); 'fr', [
        'title' => $this->randomString(),
        ]
        );
        $node->save();
        // Remove the existing file. // Remove the existing file.
        $this->submitForm([], 'Remove'); $existing_file = $node->{$this->fieldName}->entity;
        if ($existing_file) {
        $node->set($this->fieldName, NULL);
        $existing_file->delete();
        $node->save();
        }
        // Upload a different file. // Upload a different file.
        $edit = []; $default_language_node = $node->getTranslation('fr');
        $edit['title[0][value]'] = $this->randomMachineName(); $file = File::create(
        $name = 'files[' . $this->fieldName . '_0]'; [
        $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('text')[1]->uri); 'uri' => $this->drupalGetTestFiles('text')[1]->uri,
        $this->submitForm($edit, 'Save (this translation)'); ]
        );
        $file->save();
        $default_language_node->set($this->fieldName, $file->id());
        $default_language_node->save();
        $last_fid = $this->getLastFileId(); $last_fid = $this->getLastFileId();
        // Verify the translation was created. // Verify the translation was created.
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment