public function MediaResourceTestBase::testPost in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php \Drupal\Tests\media\Functional\Rest\MediaResourceTestBase::testPost()
Tests a POST request for an entity, plus edge cases to ensure good DX.
Overrides EntityResourceTestBase::testPost
File
- core/
modules/ media/ tests/ src/ Functional/ Rest/ MediaResourceTestBase.php, line 314
Class
Namespace
Drupal\Tests\media\Functional\RestCode
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());
}