public function ProviderBucketTest::testProviderBucketForm in oEmbed Providers 2.x
Tests Custom Providers add/edit form.
File
- tests/
src/ Functional/ ProviderBucketTest.php, line 104
Class
- ProviderBucketTest
- Tests the provider bucket config entity type.
Namespace
Drupal\Tests\oembed_providers\FunctionalCode
public function testProviderBucketForm() {
$this
->useFixtureProviders();
$this
->lockHttpClientToFixtures();
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('/admin/config/media/oembed-providers/buckets/add');
$page
->findField('label')
->setValue('My Test Bucket');
$page
->findField('id')
->setValue('my_test_bucket');
$page
->findField('description')
->setValue('A Description of My Test Bucket');
$page
->findField('providers[Vimeo]')
->check();
$page
->pressButton('Save');
$assert_session
->pageTextContains('The My Test Bucket oEmbed provider bucket was created.');
// Verify storage and retrieval.
$this
->drupalGet('/admin/config/media/oembed-providers/buckets/my_test_bucket/edit');
$value = $page
->findField('label')
->getValue();
$this
->AssertSame($value, 'My Test Bucket');
$value = $page
->findField('id')
->getValue();
$this
->AssertSame($value, 'my_test_bucket');
$value = $page
->findField('description')
->getValue();
$this
->AssertSame($value, 'A Description of My Test Bucket');
$assert_session
->checkboxChecked('Vimeo');
$assert_session
->checkboxNotChecked('YouTube');
// Verify media source is registered.
// There's no need to separately verify the config entity.
$media_sources = \Drupal::service('plugin.manager.media.source')
->getDefinitions();
$this
->assertArrayHasKey('oembed:my_test_bucket', $media_sources);
$this
->assertEquals($media_sources['oembed:my_test_bucket']['label'], 'My Test Bucket');
$this
->assertEquals($media_sources['oembed:my_test_bucket']['id'], 'my_test_bucket');
$this
->assertEquals($media_sources['oembed:my_test_bucket']['description'], 'A Description of My Test Bucket');
$providers = $media_sources['oembed:my_test_bucket']['providers'];
$this
->AssertTrue(in_array('Vimeo', $providers));
$this
->AssertFalse(in_array('YouTube', $providers));
}