786e36aa3954e2cfc23fed9a24d1ed7a30a953af
[yaffs-website] / web / modules / contrib / video_embed_field / tests / src / Functional / FieldConfigurationTest.php
1 <?php
2
3 namespace Drupal\Tests\video_embed_field\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Integration test for the field configuration form.
9  *
10  * @group video_embed_field
11  */
12 class FieldConfigurationTest extends BrowserTestBase {
13
14   use EntityDisplaySetupTrait;
15   use AdminUserTrait;
16
17   /**
18    * {@inheritdoc}
19    */
20   public static $modules = [
21     'field_ui',
22     'node',
23     'video_embed_field',
24   ];
25
26   /**
27    * Test the field configuration form.
28    */
29   public function testFieldConfiguration() {
30     $this->drupalLogin($this->createAdminUser());
31     $this->createContentType(['type' => 'page', 'name' => 'Page']);
32     drupal_flush_all_caches();
33     $this->drupalGet('admin/structure/types/manage/page/fields/add-field');
34     $this->submitForm([
35       'new_storage_type' => 'video_embed_field',
36       'label' => 'Video Embed',
37       'field_name' => 'video_embed',
38     ], t('Save and continue'));
39     $this->submitForm([], t('Save field settings'));
40     $this->submitForm([
41       'label' => 'Video Embed',
42       'description' => 'Some help.',
43       'required' => '1',
44       'default_value_input[field_video_embed][0][value]' => 'http://example.com',
45       'settings[allowed_providers][vimeo]' => 'vimeo',
46       'settings[allowed_providers][youtube]' => 'youtube',
47       'settings[allowed_providers][youtube_playlist]' => 'youtube_playlist',
48     ], t('Save settings'));
49     $this->assertSession()->pageTextContains('Could not find a video provider to handle the given URL.');
50     $this->submitForm([
51       'default_value_input[field_video_embed][0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
52     ], t('Save settings'));
53     $this->assertSession()->pageTextContains('Saved Video Embed configuration.');
54   }
55
56 }