Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/media/tests/src/Kernel/MediaSourceFileTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\media\Kernel; | |
4 | |
5 /** | |
6 * Tests the file media source. | |
7 * | |
8 * @group media | |
9 */ | |
10 class MediaSourceFileTest extends MediaKernelTestBase { | |
11 | |
12 /** | |
13 * Tests the file extension constraint. | |
14 */ | |
15 public function testFileExtensionConstraint() { | |
16 $mediaType = $this->createMediaType('file'); | |
17 // Create a random file that should fail. | |
18 $media = $this->generateMedia('test.patch', $mediaType); | |
19 $result = $media->validate(); | |
20 $this->assertCount(1, $result); | |
21 $this->assertEquals('field_media_file.0', $result->get(0)->getPropertyPath()); | |
22 $this->assertContains('Only files with the following extensions are allowed:', (string) $result->get(0)->getMessage()); | |
23 | |
24 // Create a random file that should pass. | |
25 $media = $this->generateMedia('test.txt', $mediaType); | |
26 $result = $media->validate(); | |
27 $this->assertCount(0, $result); | |
28 } | |
29 | |
30 } |