function MediaResourceTestBase::testPost

Same name in other branches
  1. 9 core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php \Drupal\Tests\media\Functional\Rest\MediaResourceTestBase::testPost()
  2. 10 core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php \Drupal\Tests\media\Functional\Rest\MediaResourceTestBase::testPost()
  3. 11.x core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php \Drupal\Tests\media\Functional\Rest\MediaResourceTestBase::testPost()

Overrides EntityResourceTestBase::testPost

File

core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php, line 312

Class

MediaResourceTestBase

Namespace

Drupal\Tests\media\Functional\Rest

Code

public function testPost() {
    $file_storage = $this->container
        ->get('entity_type.manager')
        ->getStorage('file');
    // Step 1: upload file, results in File entity marked temporary.
    $this->uploadFile();
    $file = $file_storage->loadUnchanged(3);
    $this->assertTrue($file->isTemporary());
    $this->assertFalse($file->isPermanent());
    // Step 2: create Media entity using the File, makes File entity permanent.
    parent::testPost();
    $file = $file_storage->loadUnchanged(3);
    $this->assertFalse($file->isTemporary());
    $this->assertTrue($file->isPermanent());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.