
| Current Path : /var/www/html/dataninja.cn/core/modules/media/tests/src/Kernel/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/dataninja.cn/core/modules/media/tests/src/Kernel/MediaSourceFileTest.php |
<?php
namespace Drupal\Tests\media\Kernel;
/**
* Tests the file media source.
*
* @group media
*/
class MediaSourceFileTest extends MediaKernelTestBase {
/**
* Tests the file extension constraint.
*/
public function testFileExtensionConstraint() {
$mediaType = $this->createMediaType('file');
// Create a random file that should fail.
$media = $this->generateMedia('test.patch', $mediaType);
$result = $media->validate();
$this->assertCount(1, $result);
$this->assertSame('field_media_file.0', $result->get(0)->getPropertyPath());
$this->assertContains('Only files with the following extensions are allowed:', (string) $result->get(0)->getMessage());
// Create a random file that should pass.
$media = $this->generateMedia('test.txt', $mediaType);
$result = $media->validate();
$this->assertCount(0, $result);
}
}