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