Mercurial > hg > isophonics-drupal-site
comparison core/modules/media/tests/src/Kernel/MediaCreationTest.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
4 | 4 |
5 use Drupal\media\Entity\Media; | 5 use Drupal\media\Entity\Media; |
6 use Drupal\media\Entity\MediaType; | 6 use Drupal\media\Entity\MediaType; |
7 use Drupal\media\MediaInterface; | 7 use Drupal\media\MediaInterface; |
8 use Drupal\media\MediaTypeInterface; | 8 use Drupal\media\MediaTypeInterface; |
9 use Drupal\user\Entity\Role; | |
10 use Drupal\user\Entity\User; | |
9 | 11 |
10 /** | 12 /** |
11 * Tests creation of media types and media items. | 13 * Tests creation of media types and media items. |
12 * | 14 * |
13 * @group media | 15 * @group media |
31 $this->assertEquals('test', $test_media_type->get('source'), 'Could not assure the correct media source.'); | 33 $this->assertEquals('test', $test_media_type->get('source'), 'Could not assure the correct media source.'); |
32 // Source field is not set on the media source, but it should never | 34 // Source field is not set on the media source, but it should never |
33 // be created automatically when a config is being imported. | 35 // be created automatically when a config is being imported. |
34 $this->assertEquals(['source_field' => '', 'test_config_value' => 'Kakec'], $test_media_type->get('source_configuration'), 'Could not assure the correct media source configuration.'); | 36 $this->assertEquals(['source_field' => '', 'test_config_value' => 'Kakec'], $test_media_type->get('source_configuration'), 'Could not assure the correct media source configuration.'); |
35 $this->assertEquals(['metadata_attribute' => 'field_attribute_config_test'], $test_media_type->get('field_map'), 'Could not assure the correct field map.'); | 37 $this->assertEquals(['metadata_attribute' => 'field_attribute_config_test'], $test_media_type->get('field_map'), 'Could not assure the correct field map.'); |
38 // Check the Media Type access handler behavior. | |
39 // We grant access to the 'view label' operation to all users having | |
40 // permission to 'view media'. | |
41 $user1 = User::create([ | |
42 'name' => 'username1', | |
43 'status' => 1, | |
44 ]); | |
45 $user1->save(); | |
46 $user2 = User::create([ | |
47 'name' => 'username2', | |
48 'status' => 1, | |
49 ]); | |
50 $user2->save(); | |
51 $role = Role::create([ | |
52 'id' => 'role1', | |
53 'label' => 'role1', | |
54 ]); | |
55 $role->grantPermission('view media')->trustData()->save(); | |
56 $user2->addRole($role->id()); | |
57 $this->assertFalse($test_media_type->access('view label', $user1)); | |
58 $this->assertTrue($test_media_type->access('view label', $user2)); | |
36 } | 59 } |
37 | 60 |
38 /** | 61 /** |
39 * Tests creating a media item programmatically. | 62 * Tests creating a media item programmatically. |
40 */ | 63 */ |